<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1999

-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE DeriveFunctor #-}</span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# LANGUAGE ViewPatterns #-}</span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span class="hs-comment">-- | Analysis functions over data types. Specifically, detecting recursive types.</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- This stuff is only used for source-code decls; it's recorded in interface</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- files for imported data types.</span><span>
</span><span id="line-18"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.TyCl.Utils</span><span class="hs-special">(</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RolesInfo"><span class="hs-identifier">RolesInfo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#inferRoles"><span class="hs-identifier">inferRoles</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#checkSynCycles"><span class="hs-identifier">checkSynCycles</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#checkClassCycles"><span class="hs-identifier">checkClassCycles</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Implicits</span></span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#addTyConsToGblEnv"><span class="hs-identifier">addTyConsToGblEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkDefaultMethodType"><span class="hs-identifier">mkDefaultMethodType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Record selectors</span></span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#tcRecSelBinds"><span class="hs-identifier">tcRecSelBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkRecSelBinds"><span class="hs-identifier">mkRecSelBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkOneRecordSelector"><span class="hs-identifier">mkOneRecordSelector</span></a></span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Bind.html"><span class="hs-identifier">GHC.Tc.Gen.Bind</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Bind.html#tcValBinds"><span class="hs-identifier">tcValBinds</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier">Type</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier">Coercion</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCoercion"><span class="hs-identifier">MCoercion</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#UnivCoProvenance"><span class="hs-identifier">UnivCoProvenance</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html#unitTy"><span class="hs-identifier">unitTy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Make.html"><span class="hs-identifier">GHC.Core.Make</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Make.html#rEC_SEL_ERROR_ID"><span class="hs-identifier">rEC_SEL_ERROR_ID</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html"><span class="hs-identifier">GHC.Core.ConLike</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html"><span class="hs-identifier">GHC.Types.Name.Env</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html"><span class="hs-identifier">GHC.Types.Name.Set</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Set.html#unitFV"><span class="hs-identifier">unitFV</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html"><span class="hs-identifier">GHC.Types.Name.Reader</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#mkVarUnqual"><span class="hs-identifier">mkVarUnqual</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html"><span class="hs-identifier">GHC.Types.Id.Info</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#ltRole"><span class="hs-identifier">ltRole</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#mkBuiltinUnique"><span class="hs-identifier">mkBuiltinUnique</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html"><span class="hs-identifier">GHC.Utils.FV</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">FV</span></span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html"><span class="hs-identifier">GHC.Unit.Module</span></a></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
        Cycles in type synonym declarations
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#synonymTyConsOfType"><span class="hs-identifier hs-type">synonymTyConsOfType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- Does not look through type synonyms at all</span><span>
</span><span id="line-84"></span><span class="hs-comment">-- Return a list of synonym tycons</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- Keep this synchronized with 'expandTypeSynonyms'</span><span>
</span><span id="line-86"></span><span id="synonymTyConsOfType"><span class="annot"><span class="annottext">synonymTyConsOfType :: PredType -&gt; [TyCon]
</span><a href="GHC.Tc.TyCl.Utils.html#synonymTyConsOfType"><span class="hs-identifier hs-var hs-var">synonymTyConsOfType</span></a></span></span><span> </span><span id="local-6989586621681097185"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097185"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-87"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; [TyCon]
forall a. NameEnv a -&gt; [a]
</span><a href="GHC.Types.Name.Env.html#nameEnvElts"><span class="hs-identifier hs-var">nameEnvElts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097185"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-89"></span><span>     </span><span class="annot"><a href="#local-6989586621681097183"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html#NameEnv"><span class="hs-identifier hs-type">NameEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>  </span><span class="hs-comment">-- The NameEnv does duplicate elim</span><span>
</span><span id="line-90"></span><span>     </span><span id="local-6989586621681097183"><span class="annot"><span class="annottext">go :: PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681097181"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097181"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681097180"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681097180"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097179"><span class="hs-identifier hs-var">go_tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097181"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; NameEnv TyCon
forall {t :: * -&gt; *}. Foldable t =&gt; t PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097177"><span class="hs-identifier hs-var">go_s</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681097180"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-91"></span><span>     </span><span class="annot"><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyLit
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span>
</span><span id="line-92"></span><span>     </span><span class="annot"><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span>
</span><span id="line-93"></span><span>     </span><span class="annot"><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681097172"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097172"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681097171"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097171"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097172"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097171"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-94"></span><span>     </span><span class="annot"><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097169"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097169"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621681097168"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097168"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681097167"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097167"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097169"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097168"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097167"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-95"></span><span>     </span><span class="annot"><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarBinder
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097165"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097165"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097165"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-96"></span><span>     </span><span class="annot"><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681097163"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097163"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681097162"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097162"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097163"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097162"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-97"></span><span>     </span><span class="annot"><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621681097159"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097159"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097159"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span>     </span><span class="hs-comment">-- Note [TyCon cycles through coercions?!]</span><span>
</span><span id="line-100"></span><span>     </span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-101"></span><span>     </span><span class="hs-comment">-- Although, in principle, it's possible for a type synonym loop</span><span>
</span><span id="line-102"></span><span>     </span><span class="hs-comment">-- could go through a coercion (since a coercion can refer to</span><span>
</span><span id="line-103"></span><span>     </span><span class="hs-comment">-- a TyCon or Type), it doesn't seem possible to actually construct</span><span>
</span><span id="line-104"></span><span>     </span><span class="hs-comment">-- a Haskell program which tickles this case.  Here is an example</span><span>
</span><span id="line-105"></span><span>     </span><span class="hs-comment">-- program which causes a coercion:</span><span>
</span><span id="line-106"></span><span>     </span><span class="hs-comment">--</span><span>
</span><span id="line-107"></span><span>     </span><span class="hs-comment">--   type family Star where</span><span>
</span><span id="line-108"></span><span>     </span><span class="hs-comment">--       Star = Type</span><span>
</span><span id="line-109"></span><span>     </span><span class="hs-comment">--</span><span>
</span><span id="line-110"></span><span>     </span><span class="hs-comment">--   data T :: Star -&gt; Type</span><span>
</span><span id="line-111"></span><span>     </span><span class="hs-comment">--   data S :: forall (a :: Type). T a -&gt; Type</span><span>
</span><span id="line-112"></span><span>     </span><span class="hs-comment">--</span><span>
</span><span id="line-113"></span><span>     </span><span class="hs-comment">-- Here, the application 'T a' must first coerce a :: Type to a :: Star,</span><span>
</span><span id="line-114"></span><span>     </span><span class="hs-comment">-- witnessed by the type family.  But if we now try to make Type refer</span><span>
</span><span id="line-115"></span><span>     </span><span class="hs-comment">-- to a type synonym which in turn refers to Star, we'll run into</span><span>
</span><span id="line-116"></span><span>     </span><span class="hs-comment">-- trouble: we're trying to define and use the type constructor</span><span>
</span><span id="line-117"></span><span>     </span><span class="hs-comment">-- in the same recursive group.  Possibly this restriction will be</span><span>
</span><span id="line-118"></span><span>     </span><span class="hs-comment">-- lifted in the future but for now, this code is &quot;just for completeness</span><span>
</span><span id="line-119"></span><span>     </span><span class="hs-comment">-- sake&quot;.</span><span>
</span><span id="line-120"></span><span>     </span><span id="local-6989586621681097157"><span class="annot"><span class="annottext">go_mco :: MCoercionN -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097157"><span class="hs-identifier hs-var hs-var">go_mco</span></a></span></span><span> </span><span class="annot"><span class="annottext">MCoercionN
</span><a href="GHC.Core.TyCo.Rep.html#MRefl"><span class="hs-identifier hs-var">MRefl</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span>
</span><span id="line-121"></span><span>     </span><span class="annot"><a href="#local-6989586621681097157"><span class="hs-identifier hs-var">go_mco</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCo"><span class="hs-identifier hs-type">MCo</span></a></span><span> </span><span id="local-6989586621681097154"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097154"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097154"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-122"></span><span>
</span><span id="line-123"></span><span>     </span><span id="local-6989586621681097161"><span class="annot"><span class="annottext">go_co :: KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var hs-var">go_co</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Refl"><span class="hs-identifier hs-type">Refl</span></a></span><span> </span><span id="local-6989586621681097152"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097152"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097152"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-124"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#GRefl"><span class="hs-identifier hs-type">GRefl</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097150"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097150"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681097149"><span class="annot"><span class="annottext">MCoercionN
</span><a href="#local-6989586621681097149"><span class="hs-identifier hs-var">mco</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097150"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">MCoercionN -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097157"><span class="hs-identifier hs-var">go_mco</span></a></span><span> </span><span class="annot"><span class="annottext">MCoercionN
</span><a href="#local-6989586621681097149"><span class="hs-identifier hs-var">mco</span></a></span><span>
</span><span id="line-125"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConAppCo"><span class="hs-identifier hs-type">TyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097147"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097147"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681097146"><span class="annot"><span class="annottext">[KindCoercion]
</span><a href="#local-6989586621681097146"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097179"><span class="hs-identifier hs-var">go_tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097147"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">[KindCoercion] -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097145"><span class="hs-identifier hs-var">go_co_s</span></a></span><span> </span><span class="annot"><span class="annottext">[KindCoercion]
</span><a href="#local-6989586621681097146"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-126"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppCo"><span class="hs-identifier hs-type">AppCo</span></a></span><span> </span><span id="local-6989586621681097143"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097143"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681097142"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097142"><span class="hs-identifier hs-var">co'</span></a></span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097143"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097142"><span class="hs-identifier hs-var">co'</span></a></span><span>
</span><span id="line-127"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllCo"><span class="hs-identifier hs-type">ForAllCo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097140"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097140"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681097139"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097139"><span class="hs-identifier hs-var">co'</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097140"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097139"><span class="hs-identifier hs-var">co'</span></a></span><span>
</span><span id="line-128"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunCo"><span class="hs-identifier hs-type">FunCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097137"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097137"><span class="hs-identifier hs-var">co_mult</span></a></span></span><span> </span><span id="local-6989586621681097136"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097136"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681097135"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097135"><span class="hs-identifier hs-var">co'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097137"><span class="hs-identifier hs-var">co_mult</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097136"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097135"><span class="hs-identifier hs-var">co'</span></a></span><span>
</span><span id="line-129"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoVarCo"><span class="hs-identifier hs-type">CoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span>
</span><span id="line-130"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#HoleCo"><span class="hs-identifier hs-type">HoleCo</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span>
</span><span id="line-131"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AxiomInstCo"><span class="hs-identifier hs-type">AxiomInstCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiom Branched
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097131"><span class="annot"><span class="annottext">[KindCoercion]
</span><a href="#local-6989586621681097131"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[KindCoercion] -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097145"><span class="hs-identifier hs-var">go_co_s</span></a></span><span> </span><span class="annot"><span class="annottext">[KindCoercion]
</span><a href="#local-6989586621681097131"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-132"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#UnivCo"><span class="hs-identifier hs-type">UnivCo</span></a></span><span> </span><span id="local-6989586621681097129"><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="#local-6989586621681097129"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097128"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097128"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681097127"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097127"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097126"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="#local-6989586621681097129"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097128"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097127"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-133"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#SymCo"><span class="hs-identifier hs-type">SymCo</span></a></span><span> </span><span id="local-6989586621681097124"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097124"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097124"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-134"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TransCo"><span class="hs-identifier hs-type">TransCo</span></a></span><span> </span><span id="local-6989586621681097122"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097122"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681097121"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097121"><span class="hs-identifier hs-var">co'</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097122"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097121"><span class="hs-identifier hs-var">co'</span></a></span><span>
</span><span id="line-135"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#NthCo"><span class="hs-identifier hs-type">NthCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097119"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097119"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097119"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-136"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LRCo"><span class="hs-identifier hs-type">LRCo</span></a></span><span> </span><span class="annot"><span class="annottext">LeftOrRight
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097117"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097117"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097117"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-137"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#InstCo"><span class="hs-identifier hs-type">InstCo</span></a></span><span> </span><span id="local-6989586621681097115"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097115"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681097114"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097114"><span class="hs-identifier hs-var">co'</span></a></span></span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097115"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097114"><span class="hs-identifier hs-var">co'</span></a></span><span>
</span><span id="line-138"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCo"><span class="hs-identifier hs-type">KindCo</span></a></span><span> </span><span id="local-6989586621681097112"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097112"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097112"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-139"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#SubCo"><span class="hs-identifier hs-type">SubCo</span></a></span><span> </span><span id="local-6989586621681097110"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097110"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097110"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-140"></span><span>     </span><span class="annot"><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AxiomRuleCo"><span class="hs-identifier hs-type">AxiomRuleCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiomRule
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681097108"><span class="annot"><span class="annottext">[KindCoercion]
</span><a href="#local-6989586621681097108"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[KindCoercion] -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097145"><span class="hs-identifier hs-var">go_co_s</span></a></span><span> </span><span class="annot"><span class="annottext">[KindCoercion]
</span><a href="#local-6989586621681097108"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-141"></span><span>
</span><span id="line-142"></span><span>     </span><span id="local-6989586621681097126"><span class="annot"><span class="annottext">go_prov :: UnivCoProvenance -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097126"><span class="hs-identifier hs-var hs-var">go_prov</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PhantomProv"><span class="hs-identifier hs-type">PhantomProv</span></a></span><span> </span><span id="local-6989586621681097106"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097106"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097106"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-143"></span><span>     </span><span class="annot"><a href="#local-6989586621681097126"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ProofIrrelProv"><span class="hs-identifier hs-type">ProofIrrelProv</span></a></span><span> </span><span id="local-6989586621681097104"><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097104"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><a href="#local-6989586621681097104"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-144"></span><span>     </span><span class="annot"><a href="#local-6989586621681097126"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PluginProv"><span class="hs-identifier hs-type">PluginProv</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span>
</span><span id="line-145"></span><span>     </span><span class="annot"><a href="#local-6989586621681097126"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="GHC.Core.TyCo.Rep.html#CorePrepProv"><span class="hs-identifier hs-var">CorePrepProv</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span>
</span><span id="line-146"></span><span>
</span><span id="line-147"></span><span>     </span><span id="local-6989586621681097179"><span class="annot"><span class="annottext">go_tc :: TyCon -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097179"><span class="hs-identifier hs-var hs-var">go_tc</span></a></span></span><span> </span><span id="local-6989586621681097101"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097101"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTypeSynonymTyCon"><span class="hs-identifier hs-var">isTypeSynonymTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097101"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TyCon -&gt; NameEnv TyCon
forall a. Name -&gt; a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#unitNameEnv"><span class="hs-identifier hs-var">unitNameEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097101"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097101"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-148"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span>
</span><span id="line-149"></span><span>     </span><span id="local-6989586621681097177"><span class="annot"><span class="annottext">go_s :: t PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097177"><span class="hs-identifier hs-var hs-var">go_s</span></a></span></span><span> </span><span id="local-6989586621681097095"><span class="annot"><span class="annottext">t PredType
</span><a href="#local-6989586621681097095"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(PredType -&gt; NameEnv TyCon -&gt; NameEnv TyCon)
-&gt; NameEnv TyCon -&gt; t PredType -&gt; NameEnv TyCon
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-identifier hs-var">plusNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">(NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon)
-&gt; (PredType -&gt; NameEnv TyCon)
-&gt; PredType
-&gt; NameEnv TyCon
-&gt; NameEnv TyCon
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097183"><span class="hs-identifier hs-var">go</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">t PredType
</span><a href="#local-6989586621681097095"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-150"></span><span>     </span><span id="local-6989586621681097145"><span class="annot"><span class="annottext">go_co_s :: [KindCoercion] -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097145"><span class="hs-identifier hs-var hs-var">go_co_s</span></a></span></span><span> </span><span id="local-6989586621681097092"><span class="annot"><span class="annottext">[KindCoercion]
</span><a href="#local-6989586621681097092"><span class="hs-identifier hs-var">cos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(KindCoercion -&gt; NameEnv TyCon -&gt; NameEnv TyCon)
-&gt; NameEnv TyCon -&gt; [KindCoercion] -&gt; NameEnv TyCon
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-identifier hs-var">plusNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">(NameEnv TyCon -&gt; NameEnv TyCon -&gt; NameEnv TyCon)
-&gt; (KindCoercion -&gt; NameEnv TyCon)
-&gt; KindCoercion
-&gt; NameEnv TyCon
-&gt; NameEnv TyCon
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion -&gt; NameEnv TyCon
</span><a href="#local-6989586621681097161"><span class="hs-identifier hs-var">go_co</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">NameEnv TyCon
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[KindCoercion]
</span><a href="#local-6989586621681097092"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-151"></span><span>
</span><span id="line-152"></span><span class="hs-comment">-- | A monad for type synonym cycle checking, which keeps</span><span>
</span><span id="line-153"></span><span class="hs-comment">-- track of the TyCons which are known to be acyclic, or</span><span>
</span><span id="line-154"></span><span class="hs-comment">-- a failure message reporting that a cycle was found.</span><span>
</span><span id="line-155"></span><span class="hs-keyword">newtype</span><span> </span><span id="SynCycleM"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-var">SynCycleM</span></a></span></span><span> </span><span id="local-6989586621681097588"><span class="annot"><a href="#local-6989586621681097588"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="SynCycleM"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-var">SynCycleM</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-156"></span><span>    </span><span id="runSynCycleM"><span class="annot"><span class="annottext">forall a.
SynCycleM a
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState)
</span><a href="GHC.Tc.TyCl.Utils.html#runSynCycleM"><span class="hs-identifier hs-var hs-var">runSynCycleM</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleState"><span class="hs-identifier hs-type">SynCycleState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681097588"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleState"><span class="hs-identifier hs-type">SynCycleState</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-157"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681097084"><span id="local-6989586621681097088"><span class="annot"><span class="annottext">(forall a b. (a -&gt; b) -&gt; SynCycleM a -&gt; SynCycleM b)
-&gt; (forall a b. a -&gt; SynCycleM b -&gt; SynCycleM a)
-&gt; Functor SynCycleM
forall a b. a -&gt; SynCycleM b -&gt; SynCycleM a
forall a b. (a -&gt; b) -&gt; SynCycleM a -&gt; SynCycleM b
forall (f :: * -&gt; *).
(forall a b. (a -&gt; b) -&gt; f a -&gt; f b)
-&gt; (forall a b. a -&gt; f b -&gt; f a) -&gt; Functor f
&lt;$ :: forall a b. a -&gt; SynCycleM b -&gt; SynCycleM a
$c&lt;$ :: forall a b. a -&gt; SynCycleM b -&gt; SynCycleM a
fmap :: forall a b. (a -&gt; b) -&gt; SynCycleM a -&gt; SynCycleM b
$cfmap :: forall a b. (a -&gt; b) -&gt; SynCycleM a -&gt; SynCycleM b
</span><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Functor</span></a></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-158"></span><span>
</span><span id="line-159"></span><span class="hs-keyword">type</span><span> </span><span id="SynCycleState"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleState"><span class="hs-identifier hs-var">SynCycleState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681097070"><span id="local-6989586621681097072"><span id="local-6989586621681097074"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-type">SynCycleM</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-162"></span><span>    </span><span id="local-6989586621681097068"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; SynCycleM a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621681097067"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681097067"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState))
-&gt; SynCycleM a
forall a.
(SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState))
-&gt; SynCycleM a
</span><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-var">SynCycleM</span></a></span><span> </span><span class="annot"><span class="annottext">((SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState))
 -&gt; SynCycleM a)
-&gt; (SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState))
-&gt; SynCycleM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681097066"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097066"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(a, SynCycleState) -&gt; Either (SrcSpan, SDoc) (a, SynCycleState)
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681097067"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097066"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-163"></span><span>    </span><span id="local-6989586621681097064"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. SynCycleM (a -&gt; b) -&gt; SynCycleM a -&gt; SynCycleM b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SynCycleM (a -&gt; b) -&gt; SynCycleM a -&gt; SynCycleM b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681097056"><span id="local-6989586621681097058"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-type">SynCycleM</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-166"></span><span>    </span><span id="local-6989586621681097054"><span class="annot"><span class="annottext">SynCycleM a
</span><a href="#local-6989586621681097054"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681097053"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. SynCycleM a -&gt; (a -&gt; SynCycleM b) -&gt; SynCycleM b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621681097052"><span class="annot"><span class="annottext">a -&gt; SynCycleM b
</span><a href="#local-6989586621681097052"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SynCycleState -&gt; Either (SrcSpan, SDoc) (b, SynCycleState))
-&gt; SynCycleM b
forall a.
(SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState))
-&gt; SynCycleM a
</span><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-var">SynCycleM</span></a></span><span> </span><span class="annot"><span class="annottext">((SynCycleState -&gt; Either (SrcSpan, SDoc) (b, SynCycleState))
 -&gt; SynCycleM b)
-&gt; (SynCycleState -&gt; Either (SrcSpan, SDoc) (b, SynCycleState))
-&gt; SynCycleM b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681097051"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097051"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-167"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SynCycleM a
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState)
forall a.
SynCycleM a
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState)
</span><a href="GHC.Tc.TyCl.Utils.html#runSynCycleM"><span class="hs-identifier hs-var hs-var">runSynCycleM</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleM a
</span><a href="#local-6989586621681097054"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097051"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-168"></span><span>            </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681097050"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681097050"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681097049"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097049"><span class="hs-identifier hs-var">state'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-169"></span><span>                </span><span class="annot"><span class="annottext">SynCycleM b
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) (b, SynCycleState)
forall a.
SynCycleM a
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState)
</span><a href="GHC.Tc.TyCl.Utils.html#runSynCycleM"><span class="hs-identifier hs-var hs-var">runSynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; SynCycleM b
</span><a href="#local-6989586621681097052"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681097050"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097049"><span class="hs-identifier hs-var">state'</span></a></span><span>
</span><span id="line-170"></span><span>            </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681097048"><span class="annot"><span class="annottext">(SrcSpan, SDoc)
</span><a href="#local-6989586621681097048"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(SrcSpan, SDoc) -&gt; Either (SrcSpan, SDoc) (b, SynCycleState)
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">(SrcSpan, SDoc)
</span><a href="#local-6989586621681097048"><span class="hs-identifier hs-var">err</span></a></span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#failSynCycleM"><span class="hs-identifier hs-type">failSynCycleM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-type">SynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-173"></span><span id="failSynCycleM"><span class="annot"><span class="annottext">failSynCycleM :: SrcSpan -&gt; SDoc -&gt; SynCycleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#failSynCycleM"><span class="hs-identifier hs-var hs-var">failSynCycleM</span></a></span></span><span> </span><span id="local-6989586621681097046"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681097046"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681097045"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681097045"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SynCycleState -&gt; Either (SrcSpan, SDoc) ((), SynCycleState))
-&gt; SynCycleM ()
forall a.
(SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState))
-&gt; SynCycleM a
</span><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-var">SynCycleM</span></a></span><span> </span><span class="annot"><span class="annottext">((SynCycleState -&gt; Either (SrcSpan, SDoc) ((), SynCycleState))
 -&gt; SynCycleM ())
-&gt; (SynCycleState -&gt; Either (SrcSpan, SDoc) ((), SynCycleState))
-&gt; SynCycleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">SynCycleState
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(SrcSpan, SDoc) -&gt; Either (SrcSpan, SDoc) ((), SynCycleState)
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681097046"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681097045"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>
</span><span id="line-175"></span><span class="hs-comment">-- | Test if a 'Name' is acyclic, short-circuiting if we've</span><span>
</span><span id="line-176"></span><span class="hs-comment">-- seen it already.</span><span>
</span><span id="line-177"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#checkNameIsAcyclic"><span class="hs-identifier hs-type">checkNameIsAcyclic</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-type">SynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-type">SynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-178"></span><span id="checkNameIsAcyclic"><span class="annot"><span class="annottext">checkNameIsAcyclic :: Name -&gt; SynCycleM () -&gt; SynCycleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#checkNameIsAcyclic"><span class="hs-identifier hs-var hs-var">checkNameIsAcyclic</span></a></span></span><span> </span><span id="local-6989586621681097043"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681097043"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681097042"><span class="annot"><span class="annottext">SynCycleM ()
</span><a href="#local-6989586621681097042"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SynCycleState -&gt; Either (SrcSpan, SDoc) ((), SynCycleState))
-&gt; SynCycleM ()
forall a.
(SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState))
-&gt; SynCycleM a
</span><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-var">SynCycleM</span></a></span><span> </span><span class="annot"><span class="annottext">((SynCycleState -&gt; Either (SrcSpan, SDoc) ((), SynCycleState))
 -&gt; SynCycleM ())
-&gt; (SynCycleState -&gt; Either (SrcSpan, SDoc) ((), SynCycleState))
-&gt; SynCycleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681097041"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097041"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-179"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681097043"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; SynCycleState -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097041"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-180"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">((), SynCycleState) -&gt; Either (SrcSpan, SDoc) ((), SynCycleState)
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097041"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- short circuit</span><span>
</span><span id="line-181"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SynCycleM ()
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) ((), SynCycleState)
forall a.
SynCycleM a
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState)
</span><a href="GHC.Tc.TyCl.Utils.html#runSynCycleM"><span class="hs-identifier hs-var hs-var">runSynCycleM</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleM ()
</span><a href="#local-6989586621681097042"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097041"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-182"></span><span>                </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681097039"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097039"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">((), SynCycleState) -&gt; Either (SrcSpan, SDoc) ((), SynCycleState)
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SynCycleState -&gt; Name -&gt; SynCycleState
</span><a href="GHC.Types.Name.Set.html#extendNameSet"><span class="hs-identifier hs-var">extendNameSet</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097039"><span class="hs-identifier hs-var">s'</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681097043"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-183"></span><span>                </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681097037"><span class="annot"><span class="annottext">(SrcSpan, SDoc)
</span><a href="#local-6989586621681097037"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(SrcSpan, SDoc) -&gt; Either (SrcSpan, SDoc) ((), SynCycleState)
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">(SrcSpan, SDoc)
</span><a href="#local-6989586621681097037"><span class="hs-identifier hs-var">err</span></a></span><span>
</span><span id="line-184"></span><span>
</span><span id="line-185"></span><span class="hs-comment">-- | Checks if any of the passed in 'TyCon's have cycles.</span><span>
</span><span id="line-186"></span><span class="hs-comment">-- Takes the 'Unit' of the home package (as we can avoid</span><span>
</span><span id="line-187"></span><span class="hs-comment">-- checking those TyCons: cycles never go through foreign packages) and</span><span>
</span><span id="line-188"></span><span class="hs-comment">-- the corresponding @LTyClDecl Name@ for each 'TyCon', so we</span><span>
</span><span id="line-189"></span><span class="hs-comment">-- can give better error messages.</span><span>
</span><span id="line-190"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#checkSynCycles"><span class="hs-identifier hs-type">checkSynCycles</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Unit"><span class="hs-identifier hs-type">Unit</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LTyClDecl"><span class="hs-identifier hs-type">LTyClDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-191"></span><span id="checkSynCycles"><span class="annot"><span class="annottext">checkSynCycles :: Unit -&gt; [TyCon] -&gt; [LTyClDecl GhcRn] -&gt; TcM ()
</span><a href="GHC.Tc.TyCl.Utils.html#checkSynCycles"><span class="hs-identifier hs-var hs-var">checkSynCycles</span></a></span></span><span> </span><span id="local-6989586621681097036"><span class="annot"><span class="annottext">Unit
</span><a href="#local-6989586621681097036"><span class="hs-identifier hs-var">this_uid</span></a></span></span><span> </span><span id="local-6989586621681097035"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097035"><span class="hs-identifier hs-var">tcs</span></a></span></span><span> </span><span id="local-6989586621681097034"><span class="annot"><span class="annottext">[LTyClDecl GhcRn]
</span><a href="#local-6989586621681097034"><span class="hs-identifier hs-var">tyclds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-192"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SynCycleM ()
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) ((), SynCycleState)
forall a.
SynCycleM a
-&gt; SynCycleState -&gt; Either (SrcSpan, SDoc) (a, SynCycleState)
</span><a href="GHC.Tc.TyCl.Utils.html#runSynCycleM"><span class="hs-identifier hs-var hs-var">runSynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyCon -&gt; SynCycleM ()) -&gt; [TyCon] -&gt; SynCycleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SynCycleState -&gt; [TyCon] -&gt; TyCon -&gt; SynCycleM ()
</span><a href="#local-6989586621681097032"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="GHC.Types.Name.Set.html#emptyNameSet"><span class="hs-identifier hs-var">emptyNameSet</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097035"><span class="hs-identifier hs-var">tcs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="GHC.Types.Name.Set.html#emptyNameSet"><span class="hs-identifier hs-var">emptyNameSet</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-193"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681097030"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681097030"><span class="hs-identifier hs-var">loc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681097029"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681097029"><span class="hs-identifier hs-var">err</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TcM () -&gt; TcM ()
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681097030"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM () -&gt; TcM ()) -&gt; TcM () -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; TcM ()
forall a. SDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTc"><span class="hs-identifier hs-var">failWithTc</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681097029"><span class="hs-identifier hs-var">err</span></a></span><span>
</span><span id="line-194"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="annot"><span class="annottext">((), SynCycleState)
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-195"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-196"></span><span>    </span><span class="hs-comment">-- Try our best to print the LTyClDecl for locally defined things</span><span>
</span><span id="line-197"></span><span>    </span><span id="local-6989586621681097026"><span class="annot"><span class="annottext">lcl_decls :: NameEnv (LTyClDecl GhcRn)
</span><a href="#local-6989586621681097026"><span class="hs-identifier hs-var hs-var">lcl_decls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, LTyClDecl GhcRn)] -&gt; NameEnv (LTyClDecl GhcRn)
forall a. [(Name, a)] -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#mkNameEnv"><span class="hs-identifier hs-var">mkNameEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Name] -&gt; [LTyClDecl GhcRn] -&gt; [(Name, LTyClDecl GhcRn)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyCon -&gt; Name) -&gt; [TyCon] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097035"><span class="hs-identifier hs-var">tcs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LTyClDecl GhcRn]
</span><a href="#local-6989586621681097034"><span class="hs-identifier hs-var">tyclds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span>    </span><span class="hs-comment">-- Short circuit if we've already seen this Name and concluded</span><span>
</span><span id="line-200"></span><span>    </span><span class="hs-comment">-- it was acyclic.</span><span>
</span><span id="line-201"></span><span>    </span><span class="annot"><a href="#local-6989586621681097032"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-type">SynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-202"></span><span>    </span><span id="local-6989586621681097032"><span class="annot"><span class="annottext">go :: SynCycleState -&gt; [TyCon] -&gt; TyCon -&gt; SynCycleM ()
</span><a href="#local-6989586621681097032"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681097024"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097024"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681097023"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097023"><span class="hs-identifier hs-var">seen_tcs</span></a></span></span><span> </span><span id="local-6989586621681097022"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097022"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-203"></span><span>        </span><span class="annot"><span class="annottext">Name -&gt; SynCycleM () -&gt; SynCycleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#checkNameIsAcyclic"><span class="hs-identifier hs-var">checkNameIsAcyclic</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097022"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SynCycleM () -&gt; SynCycleM ()) -&gt; SynCycleM () -&gt; SynCycleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState -&gt; [TyCon] -&gt; TyCon -&gt; SynCycleM ()
</span><a href="#local-6989586621681097021"><span class="hs-identifier hs-var">go'</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097024"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097023"><span class="hs-identifier hs-var">seen_tcs</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097022"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-204"></span><span>
</span><span id="line-205"></span><span>    </span><span class="hs-comment">-- Expand type synonyms, complaining if you find the same</span><span>
</span><span id="line-206"></span><span>    </span><span class="hs-comment">-- type synonym a second time.</span><span>
</span><span id="line-207"></span><span>    </span><span class="annot"><a href="#local-6989586621681097021"><span class="hs-identifier hs-type">go'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-type">SynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-208"></span><span>    </span><span id="local-6989586621681097021"><span class="annot"><span class="annottext">go' :: SynCycleState -&gt; [TyCon] -&gt; TyCon -&gt; SynCycleM ()
</span><a href="#local-6989586621681097021"><span class="hs-identifier hs-var hs-var">go'</span></a></span></span><span> </span><span id="local-6989586621681097020"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097020"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681097019"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097019"><span class="hs-identifier hs-var">seen_tcs</span></a></span></span><span> </span><span id="local-6989586621681097018"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097018"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-209"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681097017"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; SynCycleState -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097020"><span class="hs-identifier hs-var">so_far</span></a></span><span>
</span><span id="line-210"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; SDoc -&gt; SynCycleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#failSynCycleM"><span class="hs-identifier hs-var">failSynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCon] -&gt; TyCon
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097019"><span class="hs-identifier hs-var">seen_tcs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SynCycleM ()) -&gt; SDoc -&gt; SynCycleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-211"></span><span>                  </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cycle in type synonym declarations:&quot;</span></span><span>
</span><span id="line-212"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyCon -&gt; SDoc) -&gt; [TyCon] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="#local-6989586621681097010"><span class="hs-identifier hs-var">ppr_decl</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097019"><span class="hs-identifier hs-var">seen_tcs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-213"></span><span>        </span><span class="hs-comment">-- Optimization: we don't allow cycles through external packages,</span><span>
</span><span id="line-214"></span><span>        </span><span class="hs-comment">-- so once we find a non-local name we are guaranteed to not</span><span>
</span><span id="line-215"></span><span>        </span><span class="hs-comment">-- have a cycle.</span><span>
</span><span id="line-216"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-217"></span><span>        </span><span class="hs-comment">-- This won't hold once we get recursive packages with Backpack,</span><span>
</span><span id="line-218"></span><span>        </span><span class="hs-comment">-- but for now it's fine.</span><span>
</span><span id="line-219"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenModule Unit -&gt; Bool
forall u. GenModule (GenUnit u) -&gt; Bool
</span><a href="GHC.Unit.Module.html#isHoleModule"><span class="hs-identifier hs-var">isHoleModule</span></a></span><span> </span><span class="annot"><span class="annottext">GenModule Unit
</span><a href="#local-6989586621681097007"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-220"></span><span>               </span><span class="annot"><span class="annottext">GenModule Unit -&gt; Unit
forall unit. GenModule unit -&gt; unit
</span><a href="GHC.Unit.Types.html#moduleUnit"><span class="hs-identifier hs-var hs-var">moduleUnit</span></a></span><span> </span><span class="annot"><span class="annottext">GenModule Unit
</span><a href="#local-6989586621681097007"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">Unit -&gt; Unit -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unit
</span><a href="#local-6989586621681097036"><span class="hs-identifier hs-var">this_uid</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-221"></span><span>               </span><span class="annot"><span class="annottext">GenModule Unit -&gt; Bool
</span><a href="GHC.Unit.Types.html#isInteractiveModule"><span class="hs-identifier hs-var">isInteractiveModule</span></a></span><span> </span><span class="annot"><span class="annottext">GenModule Unit
</span><a href="#local-6989586621681097007"><span class="hs-identifier hs-var">mod</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-222"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; SynCycleM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-223"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681097003"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097003"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe PredType
</span><a href="GHC.Core.TyCon.html#synTyConRhs_maybe"><span class="hs-identifier hs-var">synTyConRhs_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097018"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-224"></span><span>            </span><span class="annot"><span class="annottext">SynCycleState -&gt; [TyCon] -&gt; PredType -&gt; SynCycleM ()
</span><a href="#local-6989586621681097001"><span class="hs-identifier hs-var">go_ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SynCycleState -&gt; Name -&gt; SynCycleState
</span><a href="GHC.Types.Name.Set.html#extendNameSet"><span class="hs-identifier hs-var">extendNameSet</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681097020"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097018"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097018"><span class="hs-identifier hs-var">tc</span></a></span><span class="annot"><span class="annottext">TyCon -&gt; [TyCon] -&gt; [TyCon]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681097019"><span class="hs-identifier hs-var">seen_tcs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681097003"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-225"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; SynCycleM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-226"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-227"></span><span>        </span><span id="local-6989586621681097017"><span class="annot"><span class="annottext">n :: Name
</span><a href="#local-6989586621681097017"><span class="hs-identifier hs-var hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681097018"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-228"></span><span>        </span><span id="local-6989586621681097007"><span class="annot"><span class="annottext">mod :: GenModule Unit
</span><a href="#local-6989586621681097007"><span class="hs-identifier hs-var hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; GenModule Unit
Name -&gt; GenModule Unit
</span><a href="GHC.Types.Name.html#nameModule"><span class="hs-identifier hs-var">nameModule</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681097017"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-229"></span><span>        </span><span id="local-6989586621681097010"><span class="annot"><span class="annottext">ppr_decl :: TyCon -&gt; SDoc
</span><a href="#local-6989586621681097010"><span class="hs-identifier hs-var hs-var">ppr_decl</span></a></span></span><span> </span><span id="local-6989586621681096999"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096999"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-230"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">NameEnv (LTyClDecl GhcRn) -&gt; Name -&gt; Maybe (LTyClDecl GhcRn)
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv (LTyClDecl GhcRn)
</span><a href="#local-6989586621681097026"><span class="hs-identifier hs-var">lcl_decls</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096997"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-231"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681096995"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096995"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681096994"><span class="annot"><span class="annottext">TyClDecl GhcRn
</span><a href="#local-6989586621681096994"><span class="hs-identifier hs-var">decl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096995"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyClDecl GhcRn -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyClDecl GhcRn
</span><a href="#local-6989586621681096994"><span class="hs-identifier hs-var">decl</span></a></span><span>
</span><span id="line-232"></span><span>            </span><span class="annot"><span class="annottext">Maybe (LTyClDecl GhcRn)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096997"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096997"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-233"></span><span>                       </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;from external module&quot;</span></span><span>
</span><span id="line-234"></span><span>         </span><span class="hs-keyword">where</span><span>
</span><span id="line-235"></span><span>          </span><span id="local-6989586621681096997"><span class="annot"><span class="annottext">n :: Name
</span><a href="#local-6989586621681096997"><span class="hs-identifier hs-var hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096999"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-236"></span><span>
</span><span id="line-237"></span><span>    </span><span class="annot"><a href="#local-6989586621681097001"><span class="hs-identifier hs-type">go_ty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#SynCycleM"><span class="hs-identifier hs-type">SynCycleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-238"></span><span>    </span><span id="local-6989586621681097001"><span class="annot"><span class="annottext">go_ty :: SynCycleState -&gt; [TyCon] -&gt; PredType -&gt; SynCycleM ()
</span><a href="#local-6989586621681097001"><span class="hs-identifier hs-var hs-var">go_ty</span></a></span></span><span> </span><span id="local-6989586621681096989"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096989"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681096988"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096988"><span class="hs-identifier hs-var">seen_tcs</span></a></span></span><span> </span><span id="local-6989586621681096987"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096987"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-239"></span><span>        </span><span class="annot"><span class="annottext">(TyCon -&gt; SynCycleM ()) -&gt; [TyCon] -&gt; SynCycleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SynCycleState -&gt; [TyCon] -&gt; TyCon -&gt; SynCycleM ()
</span><a href="#local-6989586621681097032"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096989"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096988"><span class="hs-identifier hs-var">seen_tcs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; [TyCon]
</span><a href="GHC.Tc.TyCl.Utils.html#synonymTyConsOfType"><span class="hs-identifier hs-var">synonymTyConsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096987"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span class="hs-comment">{- Note [Superclass cycle check]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The superclass cycle check for C decides if we can statically
guarantee that expanding C's superclass cycles transitively is
guaranteed to terminate.  This is a Haskell98 requirement,
but one that we lift with -XUndecidableSuperClasses.

The worry is that a superclass cycle could make the type checker loop.
More precisely, with a constraint (Given or Wanted)
    C ty1 .. tyn
one approach is to instantiate all of C's superclasses, transitively.
We can only do so if that set is finite.

This potential loop occurs only through superclasses.  This, for
example, is fine
  class C a where
    op :: C b =&gt; a -&gt; b -&gt; b
even though C's full definition uses C.

Making the check static also makes it conservative.  Eg
  type family F a
  class F a =&gt; C a
Here an instance of (F a) might mention C:
  type instance F [a] = C a
and now we'd have a loop.

The static check works like this, starting with C
  * Look at C's superclass predicates
  * If any is a type-function application,
    or is headed by a type variable, fail
  * If any has C at the head, fail
  * If any has a type class D at the head,
    make the same test with D

A tricky point is: what if there is a type variable at the head?
Consider this:
   class f (C f) =&gt; C f
   class c       =&gt; Id c
and now expand superclasses for constraint (C Id):
     C Id
 --&gt; Id (C Id)
 --&gt; C Id
 --&gt; ....
Each step expands superclasses one layer, and clearly does not terminate.
-}</span><span>
</span><span id="line-286"></span><span>
</span><span id="line-287"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#checkClassCycles"><span class="hs-identifier hs-type">checkClassCycles</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-288"></span><span class="hs-comment">-- Nothing  &lt;=&gt; ok</span><span>
</span><span id="line-289"></span><span class="hs-comment">-- Just err &lt;=&gt; possible cycle error</span><span>
</span><span id="line-290"></span><span id="checkClassCycles"><span class="annot"><span class="annottext">checkClassCycles :: Class -&gt; Maybe SDoc
</span><a href="GHC.Tc.TyCl.Utils.html#checkClassCycles"><span class="hs-identifier hs-var hs-var">checkClassCycles</span></a></span></span><span> </span><span id="local-6989586621681096986"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096986"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-291"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096985"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096985"><span class="hs-identifier hs-var">definite_cycle</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096984"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681096984"><span class="hs-identifier hs-var">err</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SynCycleState -&gt; Class -&gt; [PredType] -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096983"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SynCycleState
</span><a href="GHC.Types.Name.Set.html#unitNameSet"><span class="hs-identifier hs-var">unitNameSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096986"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-292"></span><span>                                     </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096986"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [PredType]
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTys"><span class="hs-identifier hs-var">mkTyVarTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [Id]
</span><a href="GHC.Core.Class.html#classTyVars"><span class="hs-identifier hs-var hs-var">classTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096986"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681096978"><span class="annot"><span class="annottext">herald :: SDoc
</span><a href="#local-6989586621681096978"><span class="hs-identifier hs-var hs-var">herald</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096985"><span class="hs-identifier hs-var">definite_cycle</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Superclass cycle for&quot;</span></span><span>
</span><span id="line-294"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Potential superclass cycle for&quot;</span></span><span>
</span><span id="line-295"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Maybe SDoc
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681096978"><span class="hs-identifier hs-var">herald</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096986"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-296"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681096984"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681096976"><span class="hs-identifier hs-var">hint</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-297"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-298"></span><span>    </span><span id="local-6989586621681096976"><span class="annot"><span class="annottext">hint :: SDoc
</span><a href="#local-6989586621681096976"><span class="hs-identifier hs-var hs-var">hint</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Use UndecidableSuperClasses to accept this&quot;</span></span><span>
</span><span id="line-299"></span><span>
</span><span id="line-300"></span><span>    </span><span class="hs-comment">-- Expand superclasses starting with (C a b), complaining</span><span>
</span><span id="line-301"></span><span>    </span><span class="hs-comment">-- if you find the same class a second time, or a type function</span><span>
</span><span id="line-302"></span><span>    </span><span class="hs-comment">-- or predicate headed by a type variable</span><span>
</span><span id="line-303"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-304"></span><span>    </span><span class="hs-comment">-- NB: this code duplicates TcType.transSuperClasses, but</span><span>
</span><span id="line-305"></span><span>    </span><span class="hs-comment">--     with more error message generation clobber</span><span>
</span><span id="line-306"></span><span>    </span><span class="hs-comment">-- Make sure the two stay in sync.</span><span>
</span><span id="line-307"></span><span>    </span><span class="annot"><a href="#local-6989586621681096983"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-308"></span><span>    </span><span id="local-6989586621681096983"><span class="annot"><span class="annottext">go :: SynCycleState -&gt; Class -&gt; [PredType] -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096983"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681096975"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096975"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681096974"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096974"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681096973"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096973"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Maybe (Bool, SDoc)] -&gt; Maybe (Bool, SDoc)
forall a. [Maybe a] -&gt; Maybe a
</span><a href="GHC.Data.Maybe.html#firstJusts"><span class="hs-identifier hs-var">firstJusts</span></a></span><span> </span><span class="annot"><span class="annottext">([Maybe (Bool, SDoc)] -&gt; Maybe (Bool, SDoc))
-&gt; [Maybe (Bool, SDoc)] -&gt; Maybe (Bool, SDoc)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-309"></span><span>                        </span><span class="annot"><span class="annottext">(PredType -&gt; Maybe (Bool, SDoc))
-&gt; [PredType] -&gt; [Maybe (Bool, SDoc)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SynCycleState -&gt; PredType -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096971"><span class="hs-identifier hs-var">go_pred</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096975"><span class="hs-identifier hs-var">so_far</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([PredType] -&gt; [Maybe (Bool, SDoc)])
-&gt; [PredType] -&gt; [Maybe (Bool, SDoc)]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-310"></span><span>                        </span><span class="annot"><span class="annottext">Class -&gt; [PredType] -&gt; [PredType]
</span><a href="GHC.Tc.Utils.TcType.html#immSuperClasses"><span class="hs-identifier hs-var">immSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096974"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096973"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-311"></span><span>
</span><span id="line-312"></span><span>    </span><span class="annot"><a href="#local-6989586621681096971"><span class="hs-identifier hs-type">go_pred</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-313"></span><span>       </span><span class="hs-comment">-- Nothing &lt;=&gt; ok</span><span>
</span><span id="line-314"></span><span>       </span><span class="hs-comment">-- Just (True, err)  &lt;=&gt; definite cycle</span><span>
</span><span id="line-315"></span><span>       </span><span class="hs-comment">-- Just (False, err) &lt;=&gt; possible cycle</span><span>
</span><span id="line-316"></span><span>    </span><span id="local-6989586621681096971"><span class="annot"><span class="annottext">go_pred :: SynCycleState -&gt; PredType -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096971"><span class="hs-identifier hs-var hs-var">go_pred</span></a></span></span><span> </span><span id="local-6989586621681096969"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096969"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681096968"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096968"><span class="hs-identifier hs-var">pred</span></a></span></span><span>  </span><span class="hs-comment">-- NB: tcSplitTyConApp looks through synonyms</span><span>
</span><span id="line-317"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096967"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096967"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096966"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096966"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; PredType -&gt; Maybe (TyCon, [PredType])
PredType -&gt; Maybe (TyCon, [PredType])
</span><a href="GHC.Core.Type.html#tcSplitTyConApp_maybe"><span class="hs-identifier hs-var">tcSplitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096968"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-318"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SynCycleState
-&gt; PredType -&gt; TyCon -&gt; [PredType] -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096964"><span class="hs-identifier hs-var">go_tc</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096969"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096968"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096967"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096966"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-319"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#hasTyVarHead"><span class="hs-identifier hs-var">hasTyVarHead</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096968"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-320"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, SDoc) -&gt; Maybe (Bool, SDoc)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;one of whose superclass constraints is headed by a type variable:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-321"></span><span>                         </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096968"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-322"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-323"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Bool, SDoc)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span>    </span><span class="annot"><a href="#local-6989586621681096964"><span class="hs-identifier hs-type">go_tc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-326"></span><span>    </span><span id="local-6989586621681096964"><span class="annot"><span class="annottext">go_tc :: SynCycleState
-&gt; PredType -&gt; TyCon -&gt; [PredType] -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096964"><span class="hs-identifier hs-var hs-var">go_tc</span></a></span></span><span> </span><span id="local-6989586621681096961"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096961"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681096960"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096960"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span id="local-6989586621681096959"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096959"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681096958"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096958"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-327"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isFamilyTyCon"><span class="hs-identifier hs-var">isFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096959"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-328"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, SDoc) -&gt; Maybe (Bool, SDoc)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;one of whose superclass constraints is headed by a type family:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>                        </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096960"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-330"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096956"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096956"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe Class
</span><a href="GHC.Core.TyCon.html#tyConClass_maybe"><span class="hs-identifier hs-var">tyConClass_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096959"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-331"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SynCycleState -&gt; Class -&gt; [PredType] -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096954"><span class="hs-identifier hs-var">go_cls</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096961"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096956"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096958"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-332"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">-- Equality predicate, for example</span><span>
</span><span id="line-333"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Bool, SDoc)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-334"></span><span>
</span><span id="line-335"></span><span>    </span><span class="annot"><a href="#local-6989586621681096954"><span class="hs-identifier hs-type">go_cls</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-336"></span><span>    </span><span id="local-6989586621681096954"><span class="annot"><span class="annottext">go_cls :: SynCycleState -&gt; Class -&gt; [PredType] -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096954"><span class="hs-identifier hs-var hs-var">go_cls</span></a></span></span><span> </span><span id="local-6989586621681096953"><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096953"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681096952"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096952"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681096951"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096951"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-337"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096950"><span class="hs-identifier hs-var">cls_nm</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; SynCycleState -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096953"><span class="hs-identifier hs-var">so_far</span></a></span><span>
</span><span id="line-338"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, SDoc) -&gt; Maybe (Bool, SDoc)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;one of whose superclasses is&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096952"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-339"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isCTupleClass"><span class="hs-identifier hs-var">isCTupleClass</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096952"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-340"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SynCycleState -&gt; Class -&gt; [PredType] -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096983"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096953"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096952"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096951"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-341"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-342"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096948"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096948"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681096947"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681096947"><span class="hs-identifier hs-var">err</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SynCycleState -&gt; Class -&gt; [PredType] -&gt; Maybe (Bool, SDoc)
</span><a href="#local-6989586621681096983"><span class="hs-identifier hs-var">go</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SynCycleState
</span><a href="#local-6989586621681096953"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="annot"><span class="annottext">SynCycleState -&gt; Name -&gt; SynCycleState
</span><a href="GHC.Types.Name.Set.html#extendNameSet"><span class="hs-operator hs-var">`extendNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096950"><span class="hs-identifier hs-var">cls_nm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096952"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096951"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-343"></span><span>          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, SDoc) -&gt; Maybe (Bool, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096948"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;one of whose superclasses is&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096952"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-344"></span><span>                       </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681096947"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-345"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-346"></span><span>         </span><span id="local-6989586621681096950"><span class="annot"><span class="annottext">cls_nm :: Name
</span><a href="#local-6989586621681096950"><span class="hs-identifier hs-var hs-var">cls_nm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096952"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-347"></span><span>
</span><span id="line-348"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
        Role inference
*                                                                      *
************************************************************************

Note [Role inference]
~~~~~~~~~~~~~~~~~~~~~
The role inference algorithm datatype definitions to infer the roles on the
parameters. Although these roles are stored in the tycons, we can perform this
algorithm on the built tycons, as long as we don't peek at an as-yet-unknown
roles field! Ah, the magic of laziness.

First, we choose appropriate initial roles. For families and classes, roles
(including initial roles) are N. For datatypes, we start with the role in the
role annotation (if any), or otherwise use Phantom. This is done in
initialRoleEnv1.

The function irGroup then propagates role information until it reaches a
fixpoint, preferring N over (R or P) and R over P. To aid in this, we have a
monad RoleM, which is a combination reader and state monad. In its state are
the current RoleEnv, which gets updated by role propagation, and an update
bit, which we use to know whether or not we've reached the fixpoint. The
environment of RoleM contains the tycon whose parameters we are inferring, and
a VarEnv from parameters to their positions, so we can update the RoleEnv.
Between tycons, this reader information is missing; it is added by
addRoleInferenceInfo.

There are two kinds of tycons to consider: algebraic ones (excluding classes)
and type synonyms. (Remember, families don't participate -- all their parameters
are N.) An algebraic tycon processes each of its datacons, in turn. Note that
a datacon's universally quantified parameters might be different from the parent
tycon's parameters, so we use the datacon's univ parameters in the mapping from
vars to positions. Note also that we don't want to infer roles for existentials
(they're all at N, too), so we put them in the set of local variables. As an
optimisation, we skip any tycons whose roles are already all Nominal, as there
nowhere else for them to go. For synonyms, we just analyse their right-hand sides.

irType walks through a type, looking for uses of a variable of interest and
propagating role information. Because anything used under a phantom position
is at phantom and anything used under a nominal position is at nominal, the
irType function can assume that anything it sees is at representational. (The
other possibilities are pruned when they're encountered.)

The rest of the code is just plumbing.

How do we know that this algorithm is correct? It should meet the following
specification:

Let Z be a role context -- a mapping from variables to roles. The following
rules define the property (Z |- t : r), where t is a type and r is a role:

Z(a) = r'        r' &lt;= r
------------------------- RCVar
Z |- a : r

---------- RCConst
Z |- T : r               -- T is a type constructor

Z |- t1 : r
Z |- t2 : N
-------------- RCApp
Z |- t1 t2 : r

forall i&lt;=n. (r_i is R or N) implies Z |- t_i : r_i
roles(T) = r_1 .. r_n
---------------------------------------------------- RCDApp
Z |- T t_1 .. t_n : R

Z, a:N |- t : r
---------------------- RCAll
Z |- forall a:k.t : r


We also have the following rules:

For all datacon_i in type T, where a_1 .. a_n are universally quantified
and b_1 .. b_m are existentially quantified, and the arguments are t_1 .. t_p,
then if forall j&lt;=p, a_1 : r_1 .. a_n : r_n, b_1 : N .. b_m : N |- t_j : R,
then roles(T) = r_1 .. r_n

roles(-&gt;) = R, R
roles(~#) = N, N

With -dcore-lint on, the output of this algorithm is checked in checkValidRoles,
called from checkValidTycon.

Note [Role-checking data constructor arguments]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  data T a where
    MkT :: Eq b =&gt; F a -&gt; (a-&gt;a) -&gt; T (G a)

Then we want to check the roles at which 'a' is used
in MkT's type.  We want to work on the user-written type,
so we need to take into account
  * the arguments:   (F a) and (a-&gt;a)
  * the context:     C a b
  * the result type: (G a)   -- this is in the eq_spec


Note [Coercions in role inference]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Is (t |&gt; co1) representationally equal to (t |&gt; co2)? Of course they are! Changing
the kind of a type is totally irrelevant to the representation of that type. So,
we want to totally ignore coercions when doing role inference. This includes omitting
any type variables that appear in nominal positions but only within coercions.
-}</span><span>
</span><span id="line-457"></span><span>
</span><span id="line-458"></span><span class="hs-keyword">type</span><span> </span><span id="RolesInfo"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RolesInfo"><span class="hs-identifier hs-var">RolesInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-459"></span><span>
</span><span id="line-460"></span><span class="hs-keyword">type</span><span> </span><span id="RoleEnv"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleEnv"><span class="hs-identifier hs-var">RoleEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html#NameEnv"><span class="hs-identifier hs-type">NameEnv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span class="hs-special">]</span><span>        </span><span class="hs-comment">-- from tycon names to roles</span><span>
</span><span id="line-461"></span><span>
</span><span id="line-462"></span><span class="hs-comment">-- This, and any of the functions it calls, must *not* look at the roles</span><span>
</span><span id="line-463"></span><span class="hs-comment">-- field of a tycon we are inferring roles about!</span><span>
</span><span id="line-464"></span><span class="hs-comment">-- See Note [Role inference]</span><span>
</span><span id="line-465"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#inferRoles"><span class="hs-identifier hs-type">inferRoles</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Phases.html#HscSource"><span class="hs-identifier hs-type">HscSource</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RoleAnnotEnv"><span class="hs-identifier hs-type">RoleAnnotEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-466"></span><span id="inferRoles"><span class="annot"><span class="annottext">inferRoles :: HscSource -&gt; RoleAnnotEnv -&gt; [TyCon] -&gt; Name -&gt; [Role]
</span><a href="GHC.Tc.TyCl.Utils.html#inferRoles"><span class="hs-identifier hs-var hs-var">inferRoles</span></a></span></span><span> </span><span id="local-6989586621681096945"><span class="annot"><span class="annottext">HscSource
</span><a href="#local-6989586621681096945"><span class="hs-identifier hs-var">hsc_src</span></a></span></span><span> </span><span id="local-6989586621681096944"><span class="annot"><span class="annottext">RoleAnnotEnv
</span><a href="#local-6989586621681096944"><span class="hs-identifier hs-var">annots</span></a></span></span><span> </span><span id="local-6989586621681096943"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096943"><span class="hs-identifier hs-var">tycons</span></a></span></span><span>
</span><span id="line-467"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681096942"><span class="annot"><span class="annottext">role_env :: RoleEnv
</span><a href="#local-6989586621681096942"><span class="hs-identifier hs-var hs-var">role_env</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HscSource -&gt; RoleAnnotEnv -&gt; [TyCon] -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#initialRoleEnv"><span class="hs-identifier hs-var">initialRoleEnv</span></a></span><span> </span><span class="annot"><span class="annottext">HscSource
</span><a href="#local-6989586621681096945"><span class="hs-identifier hs-var">hsc_src</span></a></span><span> </span><span class="annot"><span class="annottext">RoleAnnotEnv
</span><a href="#local-6989586621681096944"><span class="hs-identifier hs-var">annots</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096943"><span class="hs-identifier hs-var">tycons</span></a></span><span>
</span><span id="line-468"></span><span>        </span><span id="local-6989586621681096940"><span class="annot"><span class="annottext">role_env' :: RoleEnv
</span><a href="#local-6989586621681096940"><span class="hs-identifier hs-var hs-var">role_env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleEnv -&gt; [TyCon] -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#irGroup"><span class="hs-identifier hs-var">irGroup</span></a></span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096942"><span class="hs-identifier hs-var">role_env</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096943"><span class="hs-identifier hs-var">tycons</span></a></span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-469"></span><span>    </span><span class="hs-glyph">\</span><span id="local-6989586621681096938"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096938"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RoleEnv -&gt; Name -&gt; Maybe [Role]
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096940"><span class="hs-identifier hs-var">role_env'</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096938"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-470"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096937"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096937"><span class="hs-identifier hs-var">roles</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096937"><span class="hs-identifier hs-var">roles</span></a></span><span>
</span><span id="line-471"></span><span>      </span><span class="annot"><span class="annottext">Maybe [Role]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; [Role]
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;inferRoles&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096938"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#initialRoleEnv"><span class="hs-identifier hs-type">initialRoleEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Phases.html#HscSource"><span class="hs-identifier hs-type">HscSource</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RoleAnnotEnv"><span class="hs-identifier hs-type">RoleAnnotEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleEnv"><span class="hs-identifier hs-type">RoleEnv</span></a></span><span>
</span><span id="line-474"></span><span id="initialRoleEnv"><span class="annot"><span class="annottext">initialRoleEnv :: HscSource -&gt; RoleAnnotEnv -&gt; [TyCon] -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#initialRoleEnv"><span class="hs-identifier hs-var hs-var">initialRoleEnv</span></a></span></span><span> </span><span id="local-6989586621681096935"><span class="annot"><span class="annottext">HscSource
</span><a href="#local-6989586621681096935"><span class="hs-identifier hs-var">hsc_src</span></a></span></span><span> </span><span id="local-6989586621681096934"><span class="annot"><span class="annottext">RoleAnnotEnv
</span><a href="#local-6989586621681096934"><span class="hs-identifier hs-var">annots</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleEnv -&gt; [(Name, [Role])] -&gt; RoleEnv
forall a. NameEnv a -&gt; [(Name, a)] -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#extendNameEnvList"><span class="hs-identifier hs-var">extendNameEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">RoleEnv
forall a. NameEnv a
</span><a href="GHC.Types.Name.Env.html#emptyNameEnv"><span class="hs-identifier hs-var">emptyNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">([(Name, [Role])] -&gt; RoleEnv)
-&gt; ([TyCon] -&gt; [(Name, [Role])]) -&gt; [TyCon] -&gt; RoleEnv
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-475"></span><span>                                </span><span class="annot"><span class="annottext">(TyCon -&gt; (Name, [Role])) -&gt; [TyCon] -&gt; [(Name, [Role])]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HscSource -&gt; RoleAnnotEnv -&gt; TyCon -&gt; (Name, [Role])
</span><a href="GHC.Tc.TyCl.Utils.html#initialRoleEnv1"><span class="hs-identifier hs-var">initialRoleEnv1</span></a></span><span> </span><span class="annot"><span class="annottext">HscSource
</span><a href="#local-6989586621681096935"><span class="hs-identifier hs-var">hsc_src</span></a></span><span> </span><span class="annot"><span class="annottext">RoleAnnotEnv
</span><a href="#local-6989586621681096934"><span class="hs-identifier hs-var">annots</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-476"></span><span>
</span><span id="line-477"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#initialRoleEnv1"><span class="hs-identifier hs-type">initialRoleEnv1</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Phases.html#HscSource"><span class="hs-identifier hs-type">HscSource</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RoleAnnotEnv"><span class="hs-identifier hs-type">RoleAnnotEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-478"></span><span id="initialRoleEnv1"><span class="annot"><span class="annottext">initialRoleEnv1 :: HscSource -&gt; RoleAnnotEnv -&gt; TyCon -&gt; (Name, [Role])
</span><a href="GHC.Tc.TyCl.Utils.html#initialRoleEnv1"><span class="hs-identifier hs-var hs-var">initialRoleEnv1</span></a></span></span><span> </span><span id="local-6989586621681096931"><span class="annot"><span class="annottext">HscSource
</span><a href="#local-6989586621681096931"><span class="hs-identifier hs-var">hsc_src</span></a></span></span><span> </span><span id="local-6989586621681096930"><span class="annot"><span class="annottext">RoleAnnotEnv
</span><a href="#local-6989586621681096930"><span class="hs-identifier hs-var">annots_env</span></a></span></span><span> </span><span id="local-6989586621681096929"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-479"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isFamilyTyCon"><span class="hs-identifier hs-var">isFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096928"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(TyConBinder -&gt; Role) -&gt; [TyConBinder] -&gt; [Role]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TyConBinder -&gt; Role
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681096925"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-480"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isAlgTyCon"><span class="hs-identifier hs-var">isAlgTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096928"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096923"><span class="hs-identifier hs-var">default_roles</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-481"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTypeSynonymTyCon"><span class="hs-identifier hs-var">isTypeSynonymTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096928"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096923"><span class="hs-identifier hs-var">default_roles</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-482"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; (Name, [Role])
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;initialRoleEnv1&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-483"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681096928"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681096928"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-484"></span><span>        </span><span id="local-6989586621681096925"><span class="annot"><span class="annottext">bndrs :: [TyConBinder]
</span><a href="#local-6989586621681096925"><span class="hs-identifier hs-var hs-var">bndrs</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TyConBinder]
</span><a href="GHC.Core.TyCon.html#tyConBinders"><span class="hs-identifier hs-var hs-var">tyConBinders</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-485"></span><span>        </span><span id="local-6989586621681096921"><span class="annot"><span class="annottext">argflags :: [ArgFlag]
</span><a href="#local-6989586621681096921"><span class="hs-identifier hs-var hs-var">argflags</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyConBinder -&gt; ArgFlag) -&gt; [TyConBinder] -&gt; [ArgFlag]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TyConBinder -&gt; ArgFlag
</span><a href="GHC.Core.TyCon.html#tyConBinderArgFlag"><span class="hs-identifier hs-var">tyConBinderArgFlag</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681096925"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-486"></span><span>        </span><span id="local-6989586621681096919"><span class="annot"><span class="annottext">num_exps :: Int
</span><a href="#local-6989586621681096919"><span class="hs-identifier hs-var hs-var">num_exps</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ArgFlag -&gt; Bool) -&gt; [ArgFlag] -&gt; Int
forall a. (a -&gt; Bool) -&gt; [a] -&gt; Int
</span><a href="GHC.Utils.Misc.html#count"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">ArgFlag -&gt; Bool
</span><a href="GHC.Types.Var.html#isVisibleArgFlag"><span class="hs-identifier hs-var">isVisibleArgFlag</span></a></span><span> </span><span class="annot"><span class="annottext">[ArgFlag]
</span><a href="#local-6989586621681096921"><span class="hs-identifier hs-var">argflags</span></a></span><span>
</span><span id="line-487"></span><span>
</span><span id="line-488"></span><span>          </span><span class="hs-comment">-- if the number of annotations in the role annotation decl</span><span>
</span><span id="line-489"></span><span>          </span><span class="hs-comment">-- is wrong, just ignore it. We check this in the validity check.</span><span>
</span><span id="line-490"></span><span>        </span><span id="local-6989586621681096916"><span class="annot"><span class="annottext">role_annots :: [Maybe Role]
</span><a href="#local-6989586621681096916"><span class="hs-identifier hs-var hs-var">role_annots</span></a></span></span><span>
</span><span id="line-491"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RoleAnnotEnv -&gt; Name -&gt; Maybe (LRoleAnnotDecl GhcRn)
</span><a href="GHC.Tc.Types.html#lookupRoleAnnot"><span class="hs-identifier hs-var">lookupRoleAnnot</span></a></span><span> </span><span class="annot"><span class="annottext">RoleAnnotEnv
</span><a href="#local-6989586621681096930"><span class="hs-identifier hs-var">annots_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096928"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-492"></span><span>              </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#RoleAnnotDecl"><span class="hs-identifier hs-type">RoleAnnotDecl</span></a></span><span> </span><span class="annot"><span class="annottext">XCRoleAnnotDecl GhcRn
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Located (IdP GhcRn)
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096913"><span class="annot"><span class="annottext">[Located (Maybe Role)]
</span><a href="#local-6989586621681096913"><span class="hs-identifier hs-var">annots</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-493"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Located (Maybe Role)]
</span><a href="#local-6989586621681096913"><span class="hs-identifier hs-var">annots</span></a></span><span> </span><span class="annot"><span class="annottext">[Located (Maybe Role)] -&gt; Int -&gt; Bool
forall a. [a] -&gt; Int -&gt; Bool
</span><a href="GHC.Utils.Misc.html#lengthIs"><span class="hs-operator hs-var">`lengthIs`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096919"><span class="hs-identifier hs-var">num_exps</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Located (Maybe Role) -&gt; Maybe Role)
-&gt; [Located (Maybe Role)] -&gt; [Maybe Role]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Located (Maybe Role) -&gt; Maybe Role
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">[Located (Maybe Role)]
</span><a href="#local-6989586621681096913"><span class="hs-identifier hs-var">annots</span></a></span><span>
</span><span id="line-494"></span><span>              </span><span class="annot"><span class="annottext">Maybe (LRoleAnnotDecl GhcRn)
</span><span class="hs-identifier">_</span></span><span>                              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Role -&gt; [Maybe Role]
forall a. Int -&gt; a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#replicate"><span class="hs-identifier hs-var">replicate</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096919"><span class="hs-identifier hs-var">num_exps</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Role
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-495"></span><span>        </span><span id="local-6989586621681096923"><span class="annot"><span class="annottext">default_roles :: [Role]
</span><a href="#local-6989586621681096923"><span class="hs-identifier hs-var hs-var">default_roles</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ArgFlag] -&gt; [Maybe Role] -&gt; [Role]
</span><a href="#local-6989586621681096909"><span class="hs-identifier hs-var">build_default_roles</span></a></span><span> </span><span class="annot"><span class="annottext">[ArgFlag]
</span><a href="#local-6989586621681096921"><span class="hs-identifier hs-var">argflags</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Role]
</span><a href="#local-6989586621681096916"><span class="hs-identifier hs-var">role_annots</span></a></span><span>
</span><span id="line-496"></span><span>
</span><span id="line-497"></span><span>        </span><span id="local-6989586621681096909"><span class="annot"><span class="annottext">build_default_roles :: [ArgFlag] -&gt; [Maybe Role] -&gt; [Role]
</span><a href="#local-6989586621681096909"><span class="hs-identifier hs-var hs-var">build_default_roles</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096908"><span class="annot"><span class="annottext">ArgFlag
</span><a href="#local-6989586621681096908"><span class="hs-identifier hs-var">argf</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681096907"><span class="annot"><span class="annottext">[ArgFlag]
</span><a href="#local-6989586621681096907"><span class="hs-identifier hs-var">argfs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096906"><span class="annot"><span class="annottext">Maybe Role
</span><a href="#local-6989586621681096906"><span class="hs-identifier hs-var">m_annot</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681096905"><span class="annot"><span class="annottext">[Maybe Role]
</span><a href="#local-6989586621681096905"><span class="hs-identifier hs-var">ras</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-498"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ArgFlag -&gt; Bool
</span><a href="GHC.Types.Var.html#isVisibleArgFlag"><span class="hs-identifier hs-var">isVisibleArgFlag</span></a></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><a href="#local-6989586621681096908"><span class="hs-identifier hs-var">argf</span></a></span><span>
</span><span id="line-499"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Role
</span><a href="#local-6989586621681096906"><span class="hs-identifier hs-var">m_annot</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Role -&gt; Role -&gt; Role
forall a. Maybe a -&gt; a -&gt; a
</span><a href="GHC.Data.Maybe.html#orElse"><span class="hs-operator hs-var">`orElse`</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681096903"><span class="hs-identifier hs-var">default_role</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Role -&gt; [Role] -&gt; [Role]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[ArgFlag] -&gt; [Maybe Role] -&gt; [Role]
</span><a href="#local-6989586621681096909"><span class="hs-identifier hs-var">build_default_roles</span></a></span><span> </span><span class="annot"><span class="annottext">[ArgFlag]
</span><a href="#local-6989586621681096907"><span class="hs-identifier hs-var">argfs</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Role]
</span><a href="#local-6989586621681096905"><span class="hs-identifier hs-var">ras</span></a></span><span>
</span><span id="line-500"></span><span>        </span><span class="annot"><a href="#local-6989586621681096909"><span class="hs-identifier hs-var">build_default_roles</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096902"><span class="annot"><span class="annottext">ArgFlag
</span><a href="#local-6989586621681096902"><span class="hs-identifier hs-var">_argf</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681096901"><span class="annot"><span class="annottext">[ArgFlag]
</span><a href="#local-6989586621681096901"><span class="hs-identifier hs-var">argfs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681096900"><span class="annot"><span class="annottext">[Maybe Role]
</span><a href="#local-6989586621681096900"><span class="hs-identifier hs-var">ras</span></a></span></span><span>
</span><span id="line-501"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; [Role] -&gt; [Role]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[ArgFlag] -&gt; [Maybe Role] -&gt; [Role]
</span><a href="#local-6989586621681096909"><span class="hs-identifier hs-var">build_default_roles</span></a></span><span> </span><span class="annot"><span class="annottext">[ArgFlag]
</span><a href="#local-6989586621681096901"><span class="hs-identifier hs-var">argfs</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Role]
</span><a href="#local-6989586621681096900"><span class="hs-identifier hs-var">ras</span></a></span><span>
</span><span id="line-502"></span><span>        </span><span class="annot"><a href="#local-6989586621681096909"><span class="hs-identifier hs-var">build_default_roles</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-503"></span><span>        </span><span class="annot"><a href="#local-6989586621681096909"><span class="hs-identifier hs-var">build_default_roles</span></a></span><span> </span><span class="annot"><span class="annottext">[ArgFlag]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[Maybe Role]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; [Role]
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;initialRoleEnv1 (2)&quot;</span></span><span>
</span><span id="line-504"></span><span>                                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Maybe Role] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Role]
</span><a href="#local-6989586621681096916"><span class="hs-identifier hs-var">role_annots</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-505"></span><span>
</span><span id="line-506"></span><span>        </span><span id="local-6989586621681096903"><span class="annot"><span class="annottext">default_role :: Role
</span><a href="#local-6989586621681096903"><span class="hs-identifier hs-var hs-var">default_role</span></a></span></span><span>
</span><span id="line-507"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isClassTyCon"><span class="hs-identifier hs-var">isClassTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span>
</span><span id="line-508"></span><span>          </span><span class="hs-comment">-- Note [Default roles for abstract TyCons in hs-boot/hsig]</span><span>
</span><span id="line-509"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">HscSource
</span><a href="GHC.Driver.Phases.html#HsBootFile"><span class="hs-identifier hs-var">HsBootFile</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HscSource
</span><a href="#local-6989586621681096931"><span class="hs-identifier hs-var">hsc_src</span></a></span><span>
</span><span id="line-510"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isAbstractTyCon"><span class="hs-identifier hs-var">isAbstractTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span>
</span><span id="line-511"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">HscSource
</span><a href="GHC.Driver.Phases.html#HsigFile"><span class="hs-identifier hs-var">HsigFile</span></a></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HscSource
</span><a href="#local-6989586621681096931"><span class="hs-identifier hs-var">hsc_src</span></a></span><span>
</span><span id="line-512"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isAbstractTyCon"><span class="hs-identifier hs-var">isAbstractTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096929"><span class="hs-identifier hs-var">tc</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span>
</span><span id="line-513"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Phantom"><span class="hs-identifier hs-var">Phantom</span></a></span><span>
</span><span id="line-514"></span><span>
</span><span id="line-515"></span><span class="hs-comment">-- Note [Default roles for abstract TyCons in hs-boot/hsig]</span><span>
</span><span id="line-516"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-517"></span><span class="hs-comment">-- What should the default role for an abstract TyCon be?</span><span>
</span><span id="line-518"></span><span class="hs-comment">--</span><span>
</span><span id="line-519"></span><span class="hs-comment">-- Originally, we inferred phantom role for abstract TyCons</span><span>
</span><span id="line-520"></span><span class="hs-comment">-- in hs-boot files, because the type variables were never used.</span><span>
</span><span id="line-521"></span><span class="hs-comment">--</span><span>
</span><span id="line-522"></span><span class="hs-comment">-- This was silly, because the role of the abstract TyCon</span><span>
</span><span id="line-523"></span><span class="hs-comment">-- was required to match the implementation, and the roles of</span><span>
</span><span id="line-524"></span><span class="hs-comment">-- data types are almost never phantom.  Thus, in ticket #9204,</span><span>
</span><span id="line-525"></span><span class="hs-comment">-- the default was changed so be representational (the most common case).  If</span><span>
</span><span id="line-526"></span><span class="hs-comment">-- the implementing data type was actually nominal, you'd get an easy</span><span>
</span><span id="line-527"></span><span class="hs-comment">-- to understand error, and add the role annotation yourself.</span><span>
</span><span id="line-528"></span><span class="hs-comment">--</span><span>
</span><span id="line-529"></span><span class="hs-comment">-- Then Backpack was added, and with it we added role *subtyping*</span><span>
</span><span id="line-530"></span><span class="hs-comment">-- the matching judgment: if an abstract TyCon has a nominal</span><span>
</span><span id="line-531"></span><span class="hs-comment">-- parameter, it's OK to implement it with a representational</span><span>
</span><span id="line-532"></span><span class="hs-comment">-- parameter.  But now, the representational default is not a good</span><span>
</span><span id="line-533"></span><span class="hs-comment">-- one, because you should *only* request representational if</span><span>
</span><span id="line-534"></span><span class="hs-comment">-- you're planning to do coercions. To be maximally flexible</span><span>
</span><span id="line-535"></span><span class="hs-comment">-- with what data types you will accept, you want the default</span><span>
</span><span id="line-536"></span><span class="hs-comment">-- for hsig files is nominal.  We don't allow role subtyping</span><span>
</span><span id="line-537"></span><span class="hs-comment">-- with hs-boot files (it's good practice to give an exactly</span><span>
</span><span id="line-538"></span><span class="hs-comment">-- accurate role here, because any types that use the abstract</span><span>
</span><span id="line-539"></span><span class="hs-comment">-- type will propagate the role information.)</span><span>
</span><span id="line-540"></span><span>
</span><span id="line-541"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#irGroup"><span class="hs-identifier hs-type">irGroup</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleEnv"><span class="hs-identifier hs-type">RoleEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleEnv"><span class="hs-identifier hs-type">RoleEnv</span></a></span><span>
</span><span id="line-542"></span><span id="irGroup"><span class="annot"><span class="annottext">irGroup :: RoleEnv -&gt; [TyCon] -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#irGroup"><span class="hs-identifier hs-var hs-var">irGroup</span></a></span></span><span> </span><span id="local-6989586621681096893"><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096893"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681096892"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096892"><span class="hs-identifier hs-var">tcs</span></a></span></span><span>
</span><span id="line-543"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096891"><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096891"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096890"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096890"><span class="hs-identifier hs-var">update</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleEnv -&gt; RoleM () -&gt; (RoleEnv, Bool)
</span><a href="GHC.Tc.TyCl.Utils.html#runRoleM"><span class="hs-identifier hs-var">runRoleM</span></a></span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096893"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">(RoleM () -&gt; (RoleEnv, Bool)) -&gt; RoleM () -&gt; (RoleEnv, Bool)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; RoleM ()) -&gt; [TyCon] -&gt; RoleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irTyCon"><span class="hs-identifier hs-var">irTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096892"><span class="hs-identifier hs-var">tcs</span></a></span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-544"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096890"><span class="hs-identifier hs-var">update</span></a></span><span>
</span><span id="line-545"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">RoleEnv -&gt; [TyCon] -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#irGroup"><span class="hs-identifier hs-var">irGroup</span></a></span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096891"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096892"><span class="hs-identifier hs-var">tcs</span></a></span><span>
</span><span id="line-546"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096891"><span class="hs-identifier hs-var">env'</span></a></span><span>
</span><span id="line-547"></span><span>
</span><span id="line-548"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#irTyCon"><span class="hs-identifier hs-type">irTyCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-549"></span><span id="irTyCon"><span class="annot"><span class="annottext">irTyCon :: TyCon -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irTyCon"><span class="hs-identifier hs-var hs-var">irTyCon</span></a></span></span><span> </span><span id="local-6989586621681096887"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-550"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isAlgTyCon"><span class="hs-identifier hs-var">isAlgTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-551"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681096886"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096886"><span class="hs-identifier hs-var">old_roles</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; RoleM [Role]
</span><a href="GHC.Tc.TyCl.Utils.html#lookupRoles"><span class="hs-identifier hs-var">lookupRoles</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-552"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; RoleM () -&gt; RoleM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Role -&gt; Bool) -&gt; [Role] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Role -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096886"><span class="hs-identifier hs-var">old_roles</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(RoleM () -&gt; RoleM ()) -&gt; RoleM () -&gt; RoleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>  </span><span class="hs-comment">-- also catches data families,</span><span>
</span><span id="line-553"></span><span>                                                </span><span class="hs-comment">-- which don't want or need role inference</span><span>
</span><span id="line-554"></span><span>         </span><span class="annot"><span class="annottext">TyCon -&gt; RoleM () -&gt; RoleM ()
forall a. TyCon -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#irTcTyVars"><span class="hs-identifier hs-var">irTcTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">(RoleM () -&gt; RoleM ()) -&gt; RoleM () -&gt; RoleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-555"></span><span>         </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">(PredType -&gt; RoleM ()) -&gt; [PredType] -&gt; RoleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irType"><span class="hs-identifier hs-var">irType</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [PredType]
</span><a href="GHC.Core.TyCon.html#tyConStupidTheta"><span class="hs-identifier hs-var">tyConStupidTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See #8958</span><span>
</span><span id="line-556"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe Class -&gt; (Class -&gt; RoleM ()) -&gt; RoleM ()
forall (m :: * -&gt; *) a. Monad m =&gt; Maybe a -&gt; (a -&gt; m ()) -&gt; m ()
</span><a href="GHC.Data.Maybe.html#whenIsJust"><span class="hs-identifier hs-var">whenIsJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Maybe Class
</span><a href="GHC.Core.TyCon.html#tyConClass_maybe"><span class="hs-identifier hs-var">tyConClass_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Class -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irClass"><span class="hs-identifier hs-var">irClass</span></a></span><span>
</span><span id="line-557"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(DataCon -&gt; RoleM ()) -&gt; [DataCon] -&gt; RoleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irDataCon"><span class="hs-identifier hs-var">irDataCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AlgTyConRhs -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#visibleDataCons"><span class="hs-identifier hs-var">visibleDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">(AlgTyConRhs -&gt; [DataCon]) -&gt; AlgTyConRhs -&gt; [DataCon]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; AlgTyConRhs
</span><a href="GHC.Core.TyCon.html#algTyConRhs"><span class="hs-identifier hs-var">algTyConRhs</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span class="hs-special">}</span><span>
</span><span id="line-558"></span><span>
</span><span id="line-559"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096873"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096873"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe PredType
</span><a href="GHC.Core.TyCon.html#synTyConRhs_maybe"><span class="hs-identifier hs-var">synTyConRhs_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-560"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; RoleM () -&gt; RoleM ()
forall a. TyCon -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#irTcTyVars"><span class="hs-identifier hs-var">irTcTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096887"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">(RoleM () -&gt; RoleM ()) -&gt; RoleM () -&gt; RoleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-561"></span><span>    </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irType"><span class="hs-identifier hs-var">irType</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096873"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-562"></span><span>
</span><span id="line-563"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-564"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; RoleM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-565"></span><span>
</span><span id="line-566"></span><span class="hs-comment">-- any type variable used in an associated type must be Nominal</span><span>
</span><span id="line-567"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#irClass"><span class="hs-identifier hs-type">irClass</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-568"></span><span id="irClass"><span class="annot"><span class="annottext">irClass :: Class -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irClass"><span class="hs-identifier hs-var hs-var">irClass</span></a></span></span><span> </span><span id="local-6989586621681096872"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096872"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-569"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; RoleM ()) -&gt; [TyCon] -&gt; RoleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; RoleM ()
</span><a href="#local-6989586621681096871"><span class="hs-identifier hs-var">ir_at</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [TyCon]
</span><a href="GHC.Core.Class.html#classATs"><span class="hs-identifier hs-var">classATs</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096872"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-570"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-571"></span><span>    </span><span id="local-6989586621681096869"><span class="annot"><span class="annottext">cls_tvs :: [Id]
</span><a href="#local-6989586621681096869"><span class="hs-identifier hs-var hs-var">cls_tvs</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [Id]
</span><a href="GHC.Core.Class.html#classTyVars"><span class="hs-identifier hs-var hs-var">classTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096872"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-572"></span><span>    </span><span id="local-6989586621681096868"><span class="annot"><span class="annottext">cls_tv_set :: VarSet
</span><a href="#local-6989586621681096868"><span class="hs-identifier hs-var hs-var">cls_tv_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096869"><span class="hs-identifier hs-var">cls_tvs</span></a></span><span>
</span><span id="line-573"></span><span>
</span><span id="line-574"></span><span>    </span><span id="local-6989586621681096871"><span class="annot"><span class="annottext">ir_at :: TyCon -&gt; RoleM ()
</span><a href="#local-6989586621681096871"><span class="hs-identifier hs-var hs-var">ir_at</span></a></span></span><span> </span><span id="local-6989586621681096866"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096866"><span class="hs-identifier hs-var">at_tc</span></a></span></span><span>
</span><span id="line-575"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; RoleM ()) -&gt; [Id] -&gt; RoleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Id -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#updateRole"><span class="hs-identifier hs-var">updateRole</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096864"><span class="hs-identifier hs-var">nvars</span></a></span><span>
</span><span id="line-576"></span><span>      </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681096864"><span class="annot"><span class="annottext">nvars :: [Id]
</span><a href="#local-6989586621681096864"><span class="hs-identifier hs-var hs-var">nvars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; [Id]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096868"><span class="hs-identifier hs-var">cls_tv_set</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; [Id]) -&gt; [Id] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Id]
</span><a href="GHC.Core.TyCon.html#tyConTyVars"><span class="hs-identifier hs-var hs-var">tyConTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096866"><span class="hs-identifier hs-var">at_tc</span></a></span><span>
</span><span id="line-577"></span><span>
</span><span id="line-578"></span><span class="hs-comment">-- See Note [Role inference]</span><span>
</span><span id="line-579"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#irDataCon"><span class="hs-identifier hs-type">irDataCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-580"></span><span id="irDataCon"><span class="annot"><span class="annottext">irDataCon :: DataCon -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irDataCon"><span class="hs-identifier hs-var hs-var">irDataCon</span></a></span></span><span> </span><span id="local-6989586621681096861"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681096861"><span class="hs-identifier hs-var">datacon</span></a></span></span><span>
</span><span id="line-581"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; RoleM () -&gt; RoleM ()
forall a. [Id] -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#setRoleInferenceVars"><span class="hs-identifier hs-var">setRoleInferenceVars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096859"><span class="hs-identifier hs-var">univ_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">(RoleM () -&gt; RoleM ()) -&gt; RoleM () -&gt; RoleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-582"></span><span>    </span><span class="annot"><span class="annottext">[Id] -&gt; (VarSet -&gt; RoleM ()) -&gt; RoleM ()
forall a. [Id] -&gt; (VarSet -&gt; RoleM a) -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#irExTyVars"><span class="hs-identifier hs-var">irExTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096857"><span class="hs-identifier hs-var">ex_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">((VarSet -&gt; RoleM ()) -&gt; RoleM ())
-&gt; (VarSet -&gt; RoleM ()) -&gt; RoleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681096856"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096856"><span class="hs-identifier hs-var">ex_var_set</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-583"></span><span>      </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">(PredType -&gt; RoleM ()) -&gt; [PredType] -&gt; RoleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irType"><span class="hs-identifier hs-var">irType</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096856"><span class="hs-identifier hs-var">ex_var_set</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[EqSpec] -&gt; [PredType]
</span><a href="GHC.Core.DataCon.html#eqSpecPreds"><span class="hs-identifier hs-var">eqSpecPreds</span></a></span><span> </span><span class="annot"><span class="annottext">[EqSpec]
</span><a href="#local-6989586621681096854"><span class="hs-identifier hs-var">eq_spec</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; [PredType] -&gt; [PredType]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096853"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; [PredType] -&gt; [PredType]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(Scaled PredType -&gt; PredType) -&gt; [Scaled PredType] -&gt; [PredType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled PredType -&gt; PredType
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled PredType]
</span><a href="#local-6989586621681096851"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-584"></span><span>         </span><span class="annot"><span class="annottext">(PredType -&gt; RoleM ()) -&gt; [PredType] -&gt; RoleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-var">markNominal</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096856"><span class="hs-identifier hs-var">ex_var_set</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; PredType) -&gt; [Id] -&gt; [PredType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096857"><span class="hs-identifier hs-var">ex_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; [PredType] -&gt; [PredType]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(Scaled PredType -&gt; PredType) -&gt; [Scaled PredType] -&gt; [PredType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled PredType -&gt; PredType
forall a. Scaled a -&gt; PredType
</span><a href="GHC.Core.TyCo.Rep.html#scaledMult"><span class="hs-identifier hs-var">scaledMult</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled PredType]
</span><a href="#local-6989586621681096851"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Field multiplicities are nominal (#18799)</span><span>
</span><span id="line-585"></span><span>      </span><span class="hs-comment">-- See Note [Role-checking data constructor arguments]</span><span>
</span><span id="line-586"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-587"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681096859"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096859"><span class="hs-identifier hs-var">univ_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096857"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096857"><span class="hs-identifier hs-var">ex_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096854"><span class="annot"><span class="annottext">[EqSpec]
</span><a href="#local-6989586621681096854"><span class="hs-identifier hs-var">eq_spec</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096853"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096853"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096851"><span class="annot"><span class="annottext">[Scaled PredType]
</span><a href="#local-6989586621681096851"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096847"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096847"><span class="hs-identifier hs-var">_res_ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-588"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon
-&gt; ([Id], [Id], [EqSpec], [PredType], [Scaled PredType], PredType)
</span><a href="GHC.Core.DataCon.html#dataConFullSig"><span class="hs-identifier hs-var">dataConFullSig</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681096861"><span class="hs-identifier hs-var">datacon</span></a></span><span>
</span><span id="line-589"></span><span>
</span><span id="line-590"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#irType"><span class="hs-identifier hs-type">irType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-591"></span><span id="irType"><span class="annot"><span class="annottext">irType :: VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#irType"><span class="hs-identifier hs-var hs-var">irType</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span>
</span><span id="line-592"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-593"></span><span>    </span><span id="local-6989586621681096845"><span class="annot"><span class="annottext">go :: VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681096834"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096834"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span id="local-6989586621681096833"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096833"><span class="hs-identifier hs-var">ty</span></a></span></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096832"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096832"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; Maybe PredType
</span><a href="GHC.Core.Type.html#coreView"><span class="hs-identifier hs-var">coreView</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096833"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-comment">-- #14101</span><span>
</span><span id="line-594"></span><span>                               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096834"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096832"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-595"></span><span>    </span><span class="annot"><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681096830"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096830"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681096829"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096829"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; RoleM () -&gt; RoleM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096829"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096830"><span class="hs-identifier hs-var">lcls</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(RoleM () -&gt; RoleM ()) -&gt; RoleM () -&gt; RoleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-596"></span><span>                                 </span><span class="annot"><span class="annottext">Role -&gt; Id -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#updateRole"><span class="hs-identifier hs-var">updateRole</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096829"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-597"></span><span>    </span><span class="annot"><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681096828"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096828"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681096827"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096827"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681096826"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096826"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096828"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096827"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM () -&gt; RoleM () -&gt; RoleM ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-var">markNominal</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096828"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096826"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-598"></span><span>    </span><span class="annot"><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681096825"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096825"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681096824"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096824"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681096823"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096823"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681096822"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096822"><span class="hs-identifier hs-var">roles</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; RoleM [Role]
</span><a href="GHC.Tc.TyCl.Utils.html#lookupRolesX"><span class="hs-identifier hs-var">lookupRolesX</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096824"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-599"></span><span>                                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Role -&gt; PredType -&gt; RoleM ()) -&gt; [Role] -&gt; [PredType] -&gt; RoleM ()
forall (m :: * -&gt; *) a b c.
Applicative m =&gt;
(a -&gt; b -&gt; m c) -&gt; [a] -&gt; [b] -&gt; m ()
</span><a href="../../base/src/Control.Monad.html#zipWithM_"><span class="hs-identifier hs-var">zipWithM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Role -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096819"><span class="hs-identifier hs-var">go_app</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096825"><span class="hs-identifier hs-var">lcls</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096822"><span class="hs-identifier hs-var">roles</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096823"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-600"></span><span>    </span><span class="annot"><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681096818"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096818"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span id="local-6989586621681096817"><span class="annot"><span class="annottext">TyCoVarBinder
</span><a href="#local-6989586621681096817"><span class="hs-identifier hs-var">tvb</span></a></span></span><span> </span><span id="local-6989586621681096816"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096816"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681096815"><span class="annot"><span class="annottext">tv :: Id
</span><a href="#local-6989586621681096815"><span class="hs-identifier hs-var hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVarBinder -&gt; Id
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarBinder
</span><a href="#local-6989586621681096817"><span class="hs-identifier hs-var">tvb</span></a></span><span>
</span><span id="line-601"></span><span>                                          </span><span id="local-6989586621681096813"><span class="annot"><span class="annottext">lcls' :: VarSet
</span><a href="#local-6989586621681096813"><span class="hs-identifier hs-var hs-var">lcls'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096818"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096815"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-602"></span><span>                                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-var">markNominal</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096818"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096815"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-603"></span><span>                                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096813"><span class="hs-identifier hs-var">lcls'</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096816"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-604"></span><span>    </span><span class="annot"><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681096811"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096811"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096810"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096810"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621681096809"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096809"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span id="local-6989586621681096808"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096808"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-var">markNominal</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096811"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096810"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM () -&gt; RoleM () -&gt; RoleM ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096811"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096809"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM () -&gt; RoleM () -&gt; RoleM ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096811"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096808"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-605"></span><span>    </span><span class="annot"><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; RoleM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-606"></span><span>      </span><span class="hs-comment">-- See Note [Coercions in role inference]</span><span>
</span><span id="line-607"></span><span>    </span><span class="annot"><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681096807"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096807"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681096806"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096806"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096807"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096806"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-608"></span><span>    </span><span class="annot"><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; RoleM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-609"></span><span>
</span><span id="line-610"></span><span>    </span><span id="local-6989586621681096819"><span class="annot"><span class="annottext">go_app :: VarSet -&gt; Role -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096819"><span class="hs-identifier hs-var hs-var">go_app</span></a></span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Phantom"><span class="hs-identifier hs-var">Phantom</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; RoleM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>                 </span><span class="hs-comment">-- nothing to do here</span><span>
</span><span id="line-611"></span><span>    </span><span class="annot"><a href="#local-6989586621681096819"><span class="hs-identifier hs-var">go_app</span></a></span><span> </span><span id="local-6989586621681096805"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096805"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span id="local-6989586621681096804"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096804"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-var">markNominal</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096805"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096804"><span class="hs-identifier hs-var">ty</span></a></span><span>  </span><span class="hs-comment">-- all vars below here are N</span><span>
</span><span id="line-612"></span><span>    </span><span class="annot"><a href="#local-6989586621681096819"><span class="hs-identifier hs-var">go_app</span></a></span><span> </span><span id="local-6989586621681096803"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096803"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span> </span><span id="local-6989586621681096802"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096802"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="#local-6989586621681096845"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096803"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096802"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-613"></span><span>
</span><span id="line-614"></span><span id="local-6989586621681097498"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#irTcTyVars"><span class="hs-identifier hs-type">irTcTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097498"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097498"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-615"></span><span id="irTcTyVars"><span class="annot"><span class="annottext">irTcTyVars :: forall a. TyCon -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#irTcTyVars"><span class="hs-identifier hs-var hs-var">irTcTyVars</span></a></span></span><span> </span><span id="local-6989586621681096800"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096800"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681096799"><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096799"><span class="hs-identifier hs-var">thing</span></a></span></span><span>
</span><span id="line-616"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RoleM a -&gt; RoleM a
forall a. Name -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#setRoleInferenceTc"><span class="hs-identifier hs-var">setRoleInferenceTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096800"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(RoleM a -&gt; RoleM a) -&gt; RoleM a -&gt; RoleM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; RoleM a
</span><a href="#local-6989586621681096797"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [Id]
</span><a href="GHC.Core.TyCon.html#tyConTyVars"><span class="hs-identifier hs-var hs-var">tyConTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096800"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-617"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-618"></span><span>    </span><span id="local-6989586621681096797"><span class="annot"><span class="annottext">go :: [Id] -&gt; RoleM a
</span><a href="#local-6989586621681096797"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096799"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-619"></span><span>    </span><span class="annot"><a href="#local-6989586621681096797"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096796"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096796"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681096795"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096795"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-var">markNominal</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096796"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-620"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; RoleM a -&gt; RoleM a
forall a. Id -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#addRoleInferenceVar"><span class="hs-identifier hs-var">addRoleInferenceVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096796"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">(RoleM a -&gt; RoleM a) -&gt; RoleM a -&gt; RoleM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; RoleM a
</span><a href="#local-6989586621681096797"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096795"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-621"></span><span>
</span><span id="line-622"></span><span id="local-6989586621681097490"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#irExTyVars"><span class="hs-identifier hs-type">irExTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Set.html#TyVarSet"><span class="hs-identifier hs-type">TyVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097490"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097490"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-623"></span><span id="irExTyVars"><span class="annot"><span class="annottext">irExTyVars :: forall a. [Id] -&gt; (VarSet -&gt; RoleM a) -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#irExTyVars"><span class="hs-identifier hs-var hs-var">irExTyVars</span></a></span></span><span> </span><span id="local-6989586621681096790"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096790"><span class="hs-identifier hs-var">orig_tvs</span></a></span></span><span> </span><span id="local-6989586621681096789"><span class="annot"><span class="annottext">VarSet -&gt; RoleM a
</span><a href="#local-6989586621681096789"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [Id] -&gt; RoleM a
</span><a href="#local-6989586621681096788"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096790"><span class="hs-identifier hs-var">orig_tvs</span></a></span><span>
</span><span id="line-624"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-625"></span><span>    </span><span id="local-6989586621681096788"><span class="annot"><span class="annottext">go :: VarSet -&gt; [Id] -&gt; RoleM a
</span><a href="#local-6989586621681096788"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681096787"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096787"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; RoleM a
</span><a href="#local-6989586621681096789"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096787"><span class="hs-identifier hs-var">lcls</span></a></span><span>
</span><span id="line-626"></span><span>    </span><span class="annot"><a href="#local-6989586621681096788"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681096786"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096786"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096785"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096785"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681096784"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096784"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-var">markNominal</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096786"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096785"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-627"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [Id] -&gt; RoleM a
</span><a href="#local-6989586621681096788"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096786"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096785"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096784"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-628"></span><span>
</span><span id="line-629"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-type">markNominal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyVarSet"><span class="hs-identifier hs-type">TyVarSet</span></a></span><span>   </span><span class="hs-comment">-- local variables</span><span>
</span><span id="line-630"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-631"></span><span id="markNominal"><span class="annot"><span class="annottext">markNominal :: VarSet -&gt; PredType -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#markNominal"><span class="hs-identifier hs-var hs-var">markNominal</span></a></span></span><span> </span><span id="local-6989586621681096783"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096783"><span class="hs-identifier hs-var">lcls</span></a></span></span><span> </span><span id="local-6989586621681096782"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096782"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681096781"><span class="annot"><span class="annottext">nvars :: [Id]
</span><a href="#local-6989586621681096781"><span class="hs-identifier hs-var hs-var">nvars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV -&gt; [Id]
</span><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier hs-var">fvVarList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#delFVs"><span class="hs-identifier hs-var">FV.delFVs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096783"><span class="hs-identifier hs-var">lcls</span></a></span><span> </span><span class="annot"><span class="annottext">(FV -&gt; FV) -&gt; FV -&gt; FV
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096782"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-632"></span><span>                      </span><span class="annot"><span class="annottext">(Id -&gt; RoleM ()) -&gt; [Id] -&gt; RoleM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Id -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#updateRole"><span class="hs-identifier hs-var">updateRole</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096781"><span class="hs-identifier hs-var">nvars</span></a></span><span>
</span><span id="line-633"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-634"></span><span>     </span><span class="hs-comment">-- get_ty_vars gets all the tyvars (no covars!) from a type *without*</span><span>
</span><span id="line-635"></span><span>     </span><span class="hs-comment">-- recurring into coercions. Recall: coercions are totally ignored during</span><span>
</span><span id="line-636"></span><span>     </span><span class="hs-comment">-- role inference. See [Coercions in role inference]</span><span>
</span><span id="line-637"></span><span>    </span><span class="annot"><a href="#local-6989586621681096778"><span class="hs-identifier hs-type">get_ty_vars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-638"></span><span>    </span><span id="local-6989586621681096778"><span class="annot"><span class="annottext">get_ty_vars :: PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var hs-var">get_ty_vars</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681096777"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096777"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; FV
</span><a href="GHC.Utils.FV.html#unitFV"><span class="hs-identifier hs-var">unitFV</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096777"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-639"></span><span>    </span><span class="annot"><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681096775"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096775"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681096774"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096774"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096775"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#unionFV"><span class="hs-operator hs-var">`unionFV`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096774"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-640"></span><span>    </span><span class="annot"><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096772"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096772"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621681096771"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096771"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681096770"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096770"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096772"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#unionFV"><span class="hs-operator hs-var">`unionFV`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096771"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#unionFV"><span class="hs-operator hs-var">`unionFV`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096770"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-641"></span><span>    </span><span class="annot"><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096769"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096769"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(PredType -&gt; FV) -&gt; [PredType] -&gt; FV
forall a. (a -&gt; FV) -&gt; [a] -&gt; FV
</span><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-identifier hs-var">mapUnionFV</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096769"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-642"></span><span>    </span><span class="annot"><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span id="local-6989586621681096767"><span class="annot"><span class="annottext">TyCoVarBinder
</span><a href="#local-6989586621681096767"><span class="hs-identifier hs-var">tvb</span></a></span></span><span> </span><span id="local-6989586621681096766"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096766"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVarBinder -&gt; FV -&gt; FV
</span><a href="GHC.Core.TyCo.FVs.html#tyCoFVsBndr"><span class="hs-identifier hs-var">tyCoFVsBndr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarBinder
</span><a href="#local-6989586621681096767"><span class="hs-identifier hs-var">tvb</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096766"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-643"></span><span>    </span><span class="annot"><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="GHC.Utils.FV.html#emptyFV"><span class="hs-identifier hs-var">emptyFV</span></a></span><span>
</span><span id="line-644"></span><span>    </span><span class="annot"><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681096763"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096763"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; FV
</span><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096763"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-645"></span><span>    </span><span class="annot"><a href="#local-6989586621681096778"><span class="hs-identifier hs-var">get_ty_vars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">KindCoercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="GHC.Utils.FV.html#emptyFV"><span class="hs-identifier hs-var">emptyFV</span></a></span><span>
</span><span id="line-646"></span><span>
</span><span id="line-647"></span><span class="hs-comment">-- like lookupRoles, but with Nominal tags at the end for oversaturated TyConApps</span><span>
</span><span id="line-648"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#lookupRolesX"><span class="hs-identifier hs-type">lookupRolesX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-649"></span><span id="lookupRolesX"><span class="annot"><span class="annottext">lookupRolesX :: TyCon -&gt; RoleM [Role]
</span><a href="GHC.Tc.TyCl.Utils.html#lookupRolesX"><span class="hs-identifier hs-var hs-var">lookupRolesX</span></a></span></span><span> </span><span id="local-6989586621681096762"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096762"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-650"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681096761"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096761"><span class="hs-identifier hs-var">roles</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; RoleM [Role]
</span><a href="GHC.Tc.TyCl.Utils.html#lookupRoles"><span class="hs-identifier hs-var">lookupRoles</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096762"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-651"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Role] -&gt; RoleM [Role]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">([Role] -&gt; RoleM [Role]) -&gt; [Role] -&gt; RoleM [Role]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096761"><span class="hs-identifier hs-var">roles</span></a></span><span> </span><span class="annot"><span class="annottext">[Role] -&gt; [Role] -&gt; [Role]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; [Role]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-652"></span><span>
</span><span id="line-653"></span><span class="hs-comment">-- gets the roles either from the environment or the tycon</span><span>
</span><span id="line-654"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#lookupRoles"><span class="hs-identifier hs-type">lookupRoles</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-655"></span><span id="lookupRoles"><span class="annot"><span class="annottext">lookupRoles :: TyCon -&gt; RoleM [Role]
</span><a href="GHC.Tc.TyCl.Utils.html#lookupRoles"><span class="hs-identifier hs-var hs-var">lookupRoles</span></a></span></span><span> </span><span id="local-6989586621681096759"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096759"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-656"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681096758"><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096758"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RoleM RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#getRoleEnv"><span class="hs-identifier hs-var">getRoleEnv</span></a></span><span>
</span><span id="line-657"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RoleEnv -&gt; Name -&gt; Maybe [Role]
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096758"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096759"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-658"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096756"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096756"><span class="hs-identifier hs-var">roles</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Role] -&gt; RoleM [Role]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096756"><span class="hs-identifier hs-var">roles</span></a></span><span>
</span><span id="line-659"></span><span>           </span><span class="annot"><span class="annottext">Maybe [Role]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Role] -&gt; RoleM [Role]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">([Role] -&gt; RoleM [Role]) -&gt; [Role] -&gt; RoleM [Role]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Role]
</span><a href="GHC.Core.TyCon.html#tyConRoles"><span class="hs-identifier hs-var">tyConRoles</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096759"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-660"></span><span>
</span><span id="line-661"></span><span class="hs-comment">-- tries to update a role; won't ever update a role &quot;downwards&quot;</span><span>
</span><span id="line-662"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#updateRole"><span class="hs-identifier hs-type">updateRole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-663"></span><span id="updateRole"><span class="annot"><span class="annottext">updateRole :: Role -&gt; Id -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#updateRole"><span class="hs-identifier hs-var hs-var">updateRole</span></a></span></span><span> </span><span id="local-6989586621681096754"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681096754"><span class="hs-keyword hs-var">role</span></a></span></span><span> </span><span id="local-6989586621681096753"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096753"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-664"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681096752"><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096752"><span class="hs-identifier hs-var">var_ns</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RoleM VarPositions
</span><a href="GHC.Tc.TyCl.Utils.html#getVarNs"><span class="hs-identifier hs-var">getVarNs</span></a></span><span>
</span><span id="line-665"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681096750"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096750"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RoleM Name
</span><a href="GHC.Tc.TyCl.Utils.html#getTyConName"><span class="hs-identifier hs-var">getTyConName</span></a></span><span>
</span><span id="line-666"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarPositions -&gt; Id -&gt; Maybe Int
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096752"><span class="hs-identifier hs-var">var_ns</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096753"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-667"></span><span>           </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; RoleM ()
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;updateRole&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096750"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096753"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">VarPositions -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096752"><span class="hs-identifier hs-var">var_ns</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-668"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096747"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096747"><span class="hs-identifier hs-var">n</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Int -&gt; Role -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#updateRoleEnv"><span class="hs-identifier hs-var">updateRoleEnv</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096750"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096747"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681096754"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-669"></span><span>
</span><span id="line-670"></span><span class="hs-comment">-- the state in the RoleM monad</span><span>
</span><span id="line-671"></span><span class="hs-keyword">data</span><span> </span><span id="RoleInferenceState"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleInferenceState"><span class="hs-identifier hs-var">RoleInferenceState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="RIS"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RIS"><span class="hs-identifier hs-var">RIS</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="role_env"><span class="annot"><span class="annottext">RoleInferenceState -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#role_env"><span class="hs-identifier hs-var hs-var">role_env</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleEnv"><span class="hs-identifier hs-type">RoleEnv</span></a></span><span>
</span><span id="line-672"></span><span>                              </span><span class="hs-special">,</span><span> </span><span id="update"><span class="annot"><span class="annottext">RoleInferenceState -&gt; Bool
</span><a href="GHC.Tc.TyCl.Utils.html#update"><span class="hs-identifier hs-var hs-var">update</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-673"></span><span>
</span><span id="line-674"></span><span class="hs-comment">-- the environment in the RoleM monad</span><span>
</span><span id="line-675"></span><span class="hs-keyword">type</span><span> </span><span id="VarPositions"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#VarPositions"><span class="hs-identifier hs-var">VarPositions</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-676"></span><span>
</span><span id="line-677"></span><span class="hs-comment">-- See [Role inference]</span><span>
</span><span id="line-678"></span><span class="hs-keyword">newtype</span><span> </span><span id="RoleM"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-var">RoleM</span></a></span></span><span> </span><span id="local-6989586621681097467"><span class="annot"><a href="#local-6989586621681097467"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="RM"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="unRM"><span class="annot"><span class="annottext">forall a.
RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
</span><a href="GHC.Tc.TyCl.Utils.html#unRM"><span class="hs-identifier hs-var hs-var">unRM</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-comment">-- of the tycon</span><span>
</span><span id="line-679"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#VarPositions"><span class="hs-identifier hs-type">VarPositions</span></a></span><span>
</span><span id="line-680"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>          </span><span class="hs-comment">-- size of VarPositions</span><span>
</span><span id="line-681"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleInferenceState"><span class="hs-identifier hs-type">RoleInferenceState</span></a></span><span>
</span><span id="line-682"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681097467"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleInferenceState"><span class="hs-identifier hs-type">RoleInferenceState</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-683"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096737"><span id="local-6989586621681096739"><span class="annot"><span class="annottext">(forall a b. (a -&gt; b) -&gt; RoleM a -&gt; RoleM b)
-&gt; (forall a b. a -&gt; RoleM b -&gt; RoleM a) -&gt; Functor RoleM
forall a b. a -&gt; RoleM b -&gt; RoleM a
forall a b. (a -&gt; b) -&gt; RoleM a -&gt; RoleM b
forall (f :: * -&gt; *).
(forall a b. (a -&gt; b) -&gt; f a -&gt; f b)
-&gt; (forall a b. a -&gt; f b -&gt; f a) -&gt; Functor f
&lt;$ :: forall a b. a -&gt; RoleM b -&gt; RoleM a
$c&lt;$ :: forall a b. a -&gt; RoleM b -&gt; RoleM a
fmap :: forall a b. (a -&gt; b) -&gt; RoleM a -&gt; RoleM b
$cfmap :: forall a b. (a -&gt; b) -&gt; RoleM a -&gt; RoleM b
</span><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Functor</span></a></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-684"></span><span>
</span><span id="line-685"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681096726"><span id="local-6989586621681096728"><span id="local-6989586621681096730"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-686"></span><span>    </span><span id="local-6989586621681096725"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; RoleM a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621681096724"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681096724"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; (a, RoleInferenceState))
 -&gt; RoleM a)
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; (a, RoleInferenceState))
-&gt; RoleM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Maybe Name
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096723"><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096723"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681096724"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096723"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-687"></span><span>    </span><span id="local-6989586621681096721"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. RoleM (a -&gt; b) -&gt; RoleM a -&gt; RoleM b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleM (a -&gt; b) -&gt; RoleM a -&gt; RoleM b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span><span>
</span><span id="line-688"></span><span>
</span><span id="line-689"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681096714"><span id="local-6989586621681096716"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-690"></span><span>  </span><span id="local-6989586621681096713"><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096713"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681096712"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. RoleM a -&gt; (a -&gt; RoleM b) -&gt; RoleM b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621681096711"><span class="annot"><span class="annottext">a -&gt; RoleM b
</span><a href="#local-6989586621681096711"><span class="hs-identifier hs-var">f</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (b, RoleInferenceState))
-&gt; RoleM b
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; (b, RoleInferenceState))
 -&gt; RoleM b)
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; (b, RoleInferenceState))
-&gt; RoleM b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681096710"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096710"><span class="hs-identifier hs-var">m_info</span></a></span></span><span> </span><span id="local-6989586621681096709"><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096709"><span class="hs-identifier hs-var">vps</span></a></span></span><span> </span><span id="local-6989586621681096708"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096708"><span class="hs-identifier hs-var">nvps</span></a></span></span><span> </span><span id="local-6989586621681096707"><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096707"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-691"></span><span>                  </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096706"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681096706"><span class="hs-identifier hs-var">a'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096705"><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096705"><span class="hs-identifier hs-var">state'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
forall a.
RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
</span><a href="GHC.Tc.TyCl.Utils.html#unRM"><span class="hs-identifier hs-var hs-var">unRM</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096713"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096710"><span class="hs-identifier hs-var">m_info</span></a></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096709"><span class="hs-identifier hs-var">vps</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096708"><span class="hs-identifier hs-var">nvps</span></a></span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096707"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-692"></span><span>                  </span><span class="annot"><span class="annottext">RoleM b
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (b, RoleInferenceState)
forall a.
RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
</span><a href="GHC.Tc.TyCl.Utils.html#unRM"><span class="hs-identifier hs-var hs-var">unRM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; RoleM b
</span><a href="#local-6989586621681096711"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681096706"><span class="hs-identifier hs-var">a'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096710"><span class="hs-identifier hs-var">m_info</span></a></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096709"><span class="hs-identifier hs-var">vps</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096708"><span class="hs-identifier hs-var">nvps</span></a></span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096705"><span class="hs-identifier hs-var">state'</span></a></span><span>
</span><span id="line-693"></span><span>
</span><span id="line-694"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#runRoleM"><span class="hs-identifier hs-type">runRoleM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleEnv"><span class="hs-identifier hs-type">RoleEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleEnv"><span class="hs-identifier hs-type">RoleEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span>
</span><span id="line-695"></span><span id="runRoleM"><span class="annot"><span class="annottext">runRoleM :: RoleEnv -&gt; RoleM () -&gt; (RoleEnv, Bool)
</span><a href="GHC.Tc.TyCl.Utils.html#runRoleM"><span class="hs-identifier hs-var hs-var">runRoleM</span></a></span></span><span> </span><span id="local-6989586621681096704"><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096704"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681096703"><span class="annot"><span class="annottext">RoleM ()
</span><a href="#local-6989586621681096703"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096702"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096701"><span class="hs-identifier hs-var">update</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-696"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RIS"><span class="hs-identifier hs-type">RIS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">role_env :: RoleInferenceState -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#role_env"><span class="hs-identifier hs-var">role_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681096702"><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096702"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">update :: RoleInferenceState -&gt; Bool
</span><a href="GHC.Tc.TyCl.Utils.html#update"><span class="hs-identifier hs-var">update</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681096701"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096701"><span class="hs-identifier hs-var">update</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-697"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((), RoleInferenceState) -&gt; RoleInferenceState
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">(((), RoleInferenceState) -&gt; RoleInferenceState)
-&gt; ((), RoleInferenceState) -&gt; RoleInferenceState
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM ()
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; ((), RoleInferenceState)
forall a.
RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
</span><a href="GHC.Tc.TyCl.Utils.html#unRM"><span class="hs-identifier hs-var hs-var">unRM</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM ()
</span><a href="#local-6989586621681096703"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">VarPositions
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096699"><span class="hs-identifier hs-var">state</span></a></span><span>
</span><span id="line-698"></span><span>        </span><span id="local-6989586621681096699"><span class="annot"><span class="annottext">state :: RoleInferenceState
</span><a href="#local-6989586621681096699"><span class="hs-identifier hs-var hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RIS :: RoleEnv -&gt; Bool -&gt; RoleInferenceState
</span><a href="GHC.Tc.TyCl.Utils.html#RIS"><span class="hs-identifier hs-type">RIS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">role_env :: RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#role_env"><span class="hs-identifier hs-var">role_env</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096704"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-699"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">update :: Bool
</span><a href="GHC.Tc.TyCl.Utils.html#update"><span class="hs-identifier hs-var">update</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-700"></span><span>
</span><span id="line-701"></span><span id="local-6989586621681097476"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#setRoleInferenceTc"><span class="hs-identifier hs-type">setRoleInferenceTc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097476"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097476"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-702"></span><span id="setRoleInferenceTc"><span class="annot"><span class="annottext">setRoleInferenceTc :: forall a. Name -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#setRoleInferenceTc"><span class="hs-identifier hs-var hs-var">setRoleInferenceTc</span></a></span></span><span> </span><span id="local-6989586621681096694"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096694"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681096693"><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096693"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; (a, RoleInferenceState))
 -&gt; RoleM a)
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; (a, RoleInferenceState))
-&gt; RoleM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681096692"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096692"><span class="hs-identifier hs-var">m_name</span></a></span></span><span> </span><span id="local-6989586621681096691"><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096691"><span class="hs-identifier hs-var">vps</span></a></span></span><span> </span><span id="local-6989586621681096690"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096690"><span class="hs-identifier hs-var">nvps</span></a></span></span><span> </span><span id="local-6989586621681096689"><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096689"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-703"></span><span>                                </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isNothing</span><span> </span><span class="hs-identifier">m_name</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-704"></span><span>                                </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isEmptyVarEnv</span><span> </span><span class="hs-identifier">vps</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-705"></span><span>                                </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">nvps</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-706"></span><span>                                </span><span class="annot"><span class="annottext">RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
forall a.
RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
</span><a href="GHC.Tc.TyCl.Utils.html#unRM"><span class="hs-identifier hs-var hs-var">unRM</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096693"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Maybe Name
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096694"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096691"><span class="hs-identifier hs-var">vps</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096690"><span class="hs-identifier hs-var">nvps</span></a></span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096689"><span class="hs-identifier hs-var">state</span></a></span><span>
</span><span id="line-707"></span><span>
</span><span id="line-708"></span><span id="local-6989586621681097475"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#addRoleInferenceVar"><span class="hs-identifier hs-type">addRoleInferenceVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097475"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097475"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-709"></span><span id="addRoleInferenceVar"><span class="annot"><span class="annottext">addRoleInferenceVar :: forall a. Id -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#addRoleInferenceVar"><span class="hs-identifier hs-var hs-var">addRoleInferenceVar</span></a></span></span><span> </span><span id="local-6989586621681096681"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096681"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681096680"><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096680"><span class="hs-identifier hs-var">thing</span></a></span></span><span>
</span><span id="line-710"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; (a, RoleInferenceState))
 -&gt; RoleM a)
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; (a, RoleInferenceState))
-&gt; RoleM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681096679"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096679"><span class="hs-identifier hs-var">m_name</span></a></span></span><span> </span><span id="local-6989586621681096678"><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096678"><span class="hs-identifier hs-var">vps</span></a></span></span><span> </span><span id="local-6989586621681096677"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096677"><span class="hs-identifier hs-var">nvps</span></a></span></span><span> </span><span id="local-6989586621681096676"><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096676"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-711"></span><span>    </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isJust</span><span> </span><span class="hs-identifier">m_name</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-712"></span><span>    </span><span class="annot"><span class="annottext">RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
forall a.
RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
</span><a href="GHC.Tc.TyCl.Utils.html#unRM"><span class="hs-identifier hs-var hs-var">unRM</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096680"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096679"><span class="hs-identifier hs-var">m_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarPositions -&gt; Id -&gt; Int -&gt; VarPositions
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096678"><span class="hs-identifier hs-var">vps</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096681"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096677"><span class="hs-identifier hs-var">nvps</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096677"><span class="hs-identifier hs-var">nvps</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096676"><span class="hs-identifier hs-var">state</span></a></span><span>
</span><span id="line-713"></span><span>
</span><span id="line-714"></span><span id="local-6989586621681097491"><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#setRoleInferenceVars"><span class="hs-identifier hs-type">setRoleInferenceVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097491"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681097491"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-715"></span><span id="setRoleInferenceVars"><span class="annot"><span class="annottext">setRoleInferenceVars :: forall a. [Id] -&gt; RoleM a -&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#setRoleInferenceVars"><span class="hs-identifier hs-var hs-var">setRoleInferenceVars</span></a></span></span><span> </span><span id="local-6989586621681096669"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096669"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681096668"><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096668"><span class="hs-identifier hs-var">thing</span></a></span></span><span>
</span><span id="line-716"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; (a, RoleInferenceState))
 -&gt; RoleM a)
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; (a, RoleInferenceState))
-&gt; RoleM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681096667"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096667"><span class="hs-identifier hs-var">m_name</span></a></span></span><span> </span><span id="local-6989586621681096666"><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096666"><span class="hs-identifier hs-var">_vps</span></a></span></span><span> </span><span id="local-6989586621681096665"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096665"><span class="hs-identifier hs-var">_nvps</span></a></span></span><span> </span><span id="local-6989586621681096664"><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096664"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-717"></span><span>    </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isJust</span><span> </span><span class="hs-identifier">m_name</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-718"></span><span>    </span><span class="annot"><span class="annottext">RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
forall a.
RoleM a
-&gt; Maybe Name
-&gt; VarPositions
-&gt; Int
-&gt; RoleInferenceState
-&gt; (a, RoleInferenceState)
</span><a href="GHC.Tc.TyCl.Utils.html#unRM"><span class="hs-identifier hs-var hs-var">unRM</span></a></span><span> </span><span class="annot"><span class="annottext">RoleM a
</span><a href="#local-6989586621681096668"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096667"><span class="hs-identifier hs-var">m_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, Int)] -&gt; VarPositions
forall a. [(Id, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [Int] -&gt; [(Id, Int)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096669"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setRoleInferenceVars&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-719"></span><span>         </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096664"><span class="hs-identifier hs-var">state</span></a></span><span>
</span><span id="line-720"></span><span>
</span><span id="line-721"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#getRoleEnv"><span class="hs-identifier hs-type">getRoleEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleEnv"><span class="hs-identifier hs-type">RoleEnv</span></a></span><span>
</span><span id="line-722"></span><span id="getRoleEnv"><span class="annot"><span class="annottext">getRoleEnv :: RoleM RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#getRoleEnv"><span class="hs-identifier hs-var hs-var">getRoleEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (RoleEnv, RoleInferenceState))
-&gt; RoleM RoleEnv
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; (RoleEnv, RoleInferenceState))
 -&gt; RoleM RoleEnv)
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; (RoleEnv, RoleInferenceState))
-&gt; RoleM RoleEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Maybe Name
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096661"><span class="annot"><span class="annottext">state :: RoleInferenceState
</span><a href="#local-6989586621681096661"><span class="hs-identifier hs-var">state</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RIS"><span class="hs-identifier hs-type">RIS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">role_env :: RoleInferenceState -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#role_env"><span class="hs-identifier hs-var">role_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681096660"><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096660"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096660"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096661"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-723"></span><span>
</span><span id="line-724"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#getVarNs"><span class="hs-identifier hs-type">getVarNs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#VarPositions"><span class="hs-identifier hs-type">VarPositions</span></a></span><span>
</span><span id="line-725"></span><span id="getVarNs"><span class="annot"><span class="annottext">getVarNs :: RoleM VarPositions
</span><a href="GHC.Tc.TyCl.Utils.html#getVarNs"><span class="hs-identifier hs-var hs-var">getVarNs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (VarPositions, RoleInferenceState))
-&gt; RoleM VarPositions
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; (VarPositions, RoleInferenceState))
 -&gt; RoleM VarPositions)
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; (VarPositions, RoleInferenceState))
-&gt; RoleM VarPositions
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Maybe Name
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096659"><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096659"><span class="hs-identifier hs-var">vps</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096658"><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096658"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarPositions
</span><a href="#local-6989586621681096659"><span class="hs-identifier hs-var">vps</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096658"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-726"></span><span>
</span><span id="line-727"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#getTyConName"><span class="hs-identifier hs-type">getTyConName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-728"></span><span id="getTyConName"><span class="annot"><span class="annottext">getTyConName :: RoleM Name
</span><a href="GHC.Tc.TyCl.Utils.html#getTyConName"><span class="hs-identifier hs-var hs-var">getTyConName</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (Name, RoleInferenceState))
-&gt; RoleM Name
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; (Name, RoleInferenceState))
 -&gt; RoleM Name)
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; (Name, RoleInferenceState))
-&gt; RoleM Name
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681096657"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096657"><span class="hs-identifier hs-var">m_name</span></a></span></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096656"><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096656"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-729"></span><span>                    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681096657"><span class="hs-identifier hs-var">m_name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-730"></span><span>                      </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; (Name, RoleInferenceState)
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getTyConName&quot;</span></span><span>
</span><span id="line-731"></span><span>                      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096655"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096655"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096655"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096656"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-732"></span><span>
</span><span id="line-733"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#updateRoleEnv"><span class="hs-identifier hs-type">updateRoleEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RoleM"><span class="hs-identifier hs-type">RoleM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-734"></span><span id="updateRoleEnv"><span class="annot"><span class="annottext">updateRoleEnv :: Name -&gt; Int -&gt; Role -&gt; RoleM ()
</span><a href="GHC.Tc.TyCl.Utils.html#updateRoleEnv"><span class="hs-identifier hs-var hs-var">updateRoleEnv</span></a></span></span><span> </span><span id="local-6989586621681096654"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096654"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681096653"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096653"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681096652"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681096652"><span class="hs-keyword hs-var">role</span></a></span></span><span>
</span><span id="line-735"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; ((), RoleInferenceState))
-&gt; RoleM ()
forall a.
(Maybe Name
 -&gt; VarPositions
 -&gt; Int
 -&gt; RoleInferenceState
 -&gt; (a, RoleInferenceState))
-&gt; RoleM a
</span><a href="GHC.Tc.TyCl.Utils.html#RM"><span class="hs-identifier hs-var">RM</span></a></span><span> </span><span class="annot"><span class="annottext">((Maybe Name
  -&gt; VarPositions
  -&gt; Int
  -&gt; RoleInferenceState
  -&gt; ((), RoleInferenceState))
 -&gt; RoleM ())
-&gt; (Maybe Name
    -&gt; VarPositions
    -&gt; Int
    -&gt; RoleInferenceState
    -&gt; ((), RoleInferenceState))
-&gt; RoleM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Maybe Name
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">VarPositions
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096651"><span class="annot"><span class="annottext">state :: RoleInferenceState
</span><a href="#local-6989586621681096651"><span class="hs-identifier hs-var">state</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#RIS"><span class="hs-identifier hs-type">RIS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">role_env :: RoleInferenceState -&gt; RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#role_env"><span class="hs-identifier hs-var">role_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681096650"><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096650"><span class="hs-identifier hs-var">role_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-736"></span><span>         </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RoleEnv -&gt; Name -&gt; Maybe [Role]
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096650"><span class="hs-identifier hs-var">role_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096654"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-737"></span><span>           </span><span class="annot"><span class="annottext">Maybe [Role]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; RoleInferenceState
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;updateRoleEnv&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096654"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-738"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096649"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096649"><span class="hs-identifier hs-var">roles</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096648"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096648"><span class="hs-identifier hs-var">before</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096647"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681096647"><span class="hs-identifier hs-var">old_role</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681096646"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096646"><span class="hs-identifier hs-var">after</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Role] -&gt; ([Role], [Role])
forall a. Int -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#splitAt"><span class="hs-identifier hs-var">splitAt</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681096653"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096649"><span class="hs-identifier hs-var">roles</span></a></span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-739"></span><span>                         </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681096652"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; Role -&gt; Bool
</span><a href="GHC.Core.Coercion.html#ltRole"><span class="hs-operator hs-var">`ltRole`</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681096647"><span class="hs-identifier hs-var">old_role</span></a></span><span>
</span><span id="line-740"></span><span>                         </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681096644"><span class="annot"><span class="annottext">roles' :: [Role]
</span><a href="#local-6989586621681096644"><span class="hs-identifier hs-var hs-var">roles'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096648"><span class="hs-identifier hs-var">before</span></a></span><span> </span><span class="annot"><span class="annottext">[Role] -&gt; [Role] -&gt; [Role]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681096652"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; [Role] -&gt; [Role]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096646"><span class="hs-identifier hs-var">after</span></a></span><span>
</span><span id="line-741"></span><span>                                  </span><span id="local-6989586621681096643"><span class="annot"><span class="annottext">role_env' :: RoleEnv
</span><a href="#local-6989586621681096643"><span class="hs-identifier hs-var hs-var">role_env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleEnv -&gt; Name -&gt; [Role] -&gt; RoleEnv
forall a. NameEnv a -&gt; Name -&gt; a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#extendNameEnv"><span class="hs-identifier hs-var">extendNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096650"><span class="hs-identifier hs-var">role_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096654"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681096644"><span class="hs-identifier hs-var">roles'</span></a></span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-742"></span><span>                              </span><span class="annot"><span class="annottext">RIS :: RoleEnv -&gt; Bool -&gt; RoleInferenceState
</span><a href="GHC.Tc.TyCl.Utils.html#RIS"><span class="hs-identifier hs-type">RIS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">role_env :: RoleEnv
</span><a href="GHC.Tc.TyCl.Utils.html#role_env"><span class="hs-identifier hs-var">role_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RoleEnv
</span><a href="#local-6989586621681096643"><span class="hs-identifier hs-var">role_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">update :: Bool
</span><a href="GHC.Tc.TyCl.Utils.html#update"><span class="hs-identifier hs-var">update</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-743"></span><span>                         </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">RoleInferenceState
</span><a href="#local-6989586621681096651"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-744"></span><span>
</span><span id="line-745"></span><span>
</span><span id="line-746"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                Building implicits
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-751"></span><span>
</span><span id="line-752"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#addTyConsToGblEnv"><span class="hs-identifier hs-type">addTyConsToGblEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span>
</span><span id="line-753"></span><span class="hs-comment">-- Given a [TyCon], add to the TcGblEnv</span><span>
</span><span id="line-754"></span><span class="hs-comment">--   * extend the TypeEnv with the tycons</span><span>
</span><span id="line-755"></span><span class="hs-comment">--   * extend the TypeEnv with their implicitTyThings</span><span>
</span><span id="line-756"></span><span class="hs-comment">--   * extend the TypeEnv with any default method Ids</span><span>
</span><span id="line-757"></span><span class="hs-comment">--   * add bindings for record selectors</span><span>
</span><span id="line-758"></span><span id="addTyConsToGblEnv"><span class="annot"><span class="annottext">addTyConsToGblEnv :: [TyCon] -&gt; TcM TcGblEnv
</span><a href="GHC.Tc.TyCl.Utils.html#addTyConsToGblEnv"><span class="hs-identifier hs-var hs-var">addTyConsToGblEnv</span></a></span></span><span> </span><span id="local-6989586621681096641"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096641"><span class="hs-identifier hs-var">tyclss</span></a></span></span><span>
</span><span id="line-759"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCon] -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall r. [TyCon] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendTyConEnv"><span class="hs-identifier hs-var">tcExtendTyConEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096641"><span class="hs-identifier hs-var">tyclss</span></a></span><span>                    </span><span class="annot"><span class="annottext">(TcM TcGblEnv -&gt; TcM TcGblEnv) -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-760"></span><span>    </span><span class="annot"><span class="annottext">[TyThing] -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall r. [TyThing] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnvImplicit"><span class="hs-identifier hs-var">tcExtendGlobalEnvImplicit</span></a></span><span> </span><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681096638"><span class="hs-identifier hs-var">implicit_things</span></a></span><span>  </span><span class="annot"><span class="annottext">(TcM TcGblEnv -&gt; TcM TcGblEnv) -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-761"></span><span>    </span><span class="annot"><span class="annottext">[Id] -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a. [Id] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalValEnv"><span class="hs-identifier hs-var">tcExtendGlobalValEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096636"><span class="hs-identifier hs-var">def_meth_ids</span></a></span><span>          </span><span class="annot"><span class="annottext">(TcM TcGblEnv -&gt; TcM TcGblEnv) -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-762"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcAddTyCons&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-763"></span><span>            </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tycons&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096641"><span class="hs-identifier hs-var">tyclss</span></a></span><span>
</span><span id="line-764"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;implicits&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyThing] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681096638"><span class="hs-identifier hs-var">implicit_things</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-765"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681096634"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681096634"><span class="hs-identifier hs-var">gbl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, LHsBind GhcRn)] -&gt; TcM TcGblEnv
</span><a href="GHC.Tc.TyCl.Utils.html#tcRecSelBinds"><span class="hs-identifier hs-var">tcRecSelBinds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCon] -&gt; [(Id, LHsBind GhcRn)]
</span><a href="GHC.Tc.TyCl.Utils.html#mkRecSelBinds"><span class="hs-identifier hs-var">mkRecSelBinds</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096641"><span class="hs-identifier hs-var">tyclss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-766"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM TcGblEnv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681096634"><span class="hs-identifier hs-var">gbl_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-767"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-768"></span><span>   </span><span id="local-6989586621681096638"><span class="annot"><span class="annottext">implicit_things :: [TyThing]
</span><a href="#local-6989586621681096638"><span class="hs-identifier hs-var hs-var">implicit_things</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; [TyThing]) -&gt; [TyCon] -&gt; [TyThing]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TyThing]
</span><a href="GHC.Driver.Types.html#implicitTyConThings"><span class="hs-identifier hs-var">implicitTyConThings</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096641"><span class="hs-identifier hs-var">tyclss</span></a></span><span>
</span><span id="line-769"></span><span>   </span><span id="local-6989586621681096636"><span class="annot"><span class="annottext">def_meth_ids :: [Id]
</span><a href="#local-6989586621681096636"><span class="hs-identifier hs-var hs-var">def_meth_ids</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCon] -&gt; [Id]
</span><a href="GHC.Tc.TyCl.Utils.html#mkDefaultMethodIds"><span class="hs-identifier hs-var">mkDefaultMethodIds</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096641"><span class="hs-identifier hs-var">tyclss</span></a></span><span>
</span><span id="line-770"></span><span>
</span><span id="line-771"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkDefaultMethodIds"><span class="hs-identifier hs-type">mkDefaultMethodIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-772"></span><span class="hs-comment">-- We want to put the default-method Ids (both vanilla and generic)</span><span>
</span><span id="line-773"></span><span class="hs-comment">-- into the type environment so that they are found when we typecheck</span><span>
</span><span id="line-774"></span><span class="hs-comment">-- the filled-in default methods of each instance declaration</span><span>
</span><span id="line-775"></span><span class="hs-comment">-- See Note [Default method Ids and Template Haskell]</span><span>
</span><span id="line-776"></span><span id="mkDefaultMethodIds"><span class="annot"><span class="annottext">mkDefaultMethodIds :: [TyCon] -&gt; [Id]
</span><a href="GHC.Tc.TyCl.Utils.html#mkDefaultMethodIds"><span class="hs-identifier hs-var hs-var">mkDefaultMethodIds</span></a></span></span><span> </span><span id="local-6989586621681096630"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096630"><span class="hs-identifier hs-var">tycons</span></a></span></span><span>
</span><span id="line-777"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Name -&gt; PredType -&gt; Id
</span><a href="GHC.Types.Id.html#mkExportedVanillaId"><span class="hs-identifier hs-var">mkExportedVanillaId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096628"><span class="hs-identifier hs-var">dm_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Id -&gt; DefMethSpec PredType -&gt; PredType
</span><a href="GHC.Tc.TyCl.Utils.html#mkDefaultMethodType"><span class="hs-identifier hs-var">mkDefaultMethodType</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096627"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096626"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">DefMethSpec PredType
</span><a href="#local-6989586621681096625"><span class="hs-identifier hs-var">dm_spec</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-778"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681096624"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096624"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096630"><span class="hs-identifier hs-var">tycons</span></a></span><span>
</span><span id="line-779"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681096627"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096627"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TyCon -&gt; Maybe Class
</span><a href="GHC.Core.TyCon.html#tyConClass_maybe"><span class="hs-identifier hs-var">tyConClass_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096624"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-780"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096626"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096626"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096628"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096628"><span class="hs-identifier hs-var">dm_name</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096625"><span class="annot"><span class="annottext">DefMethSpec PredType
</span><a href="#local-6989586621681096625"><span class="hs-identifier hs-var">dm_spec</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [(Id, DefMethInfo)]
</span><a href="GHC.Core.Class.html#classOpItems"><span class="hs-identifier hs-var">classOpItems</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096627"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-781"></span><span>
</span><span id="line-782"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkDefaultMethodType"><span class="hs-identifier hs-type">mkDefaultMethodType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#DefMethSpec"><span class="hs-identifier hs-type">DefMethSpec</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-783"></span><span class="hs-comment">-- Returns the top-level type of the default method</span><span>
</span><span id="line-784"></span><span id="mkDefaultMethodType"><span class="annot"><span class="annottext">mkDefaultMethodType :: Class -&gt; Id -&gt; DefMethSpec PredType -&gt; PredType
</span><a href="GHC.Tc.TyCl.Utils.html#mkDefaultMethodType"><span class="hs-identifier hs-var hs-var">mkDefaultMethodType</span></a></span></span><span> </span><span class="annot"><span class="annottext">Class
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096622"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096622"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span> </span><span class="annot"><span class="annottext">DefMethSpec PredType
</span><a href="GHC.Types.Basic.html#VanillaDM"><span class="hs-identifier hs-var">VanillaDM</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096622"><span class="hs-identifier hs-var">sel_id</span></a></span><span>
</span><span id="line-785"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkDefaultMethodType"><span class="hs-identifier hs-var">mkDefaultMethodType</span></a></span><span> </span><span id="local-6989586621681096619"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096619"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#GenericDM"><span class="hs-identifier hs-type">GenericDM</span></a></span><span> </span><span id="local-6989586621681096617"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096617"><span class="hs-identifier hs-var">dm_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCoVarBinder] -&gt; [PredType] -&gt; PredType -&gt; PredType
</span><a href="GHC.Tc.Utils.TcType.html#mkSigmaTy"><span class="hs-identifier hs-var">mkSigmaTy</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVarBinder]
</span><a href="#local-6989586621681096615"><span class="hs-identifier hs-var">tv_bndrs</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096614"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096617"><span class="hs-identifier hs-var">dm_ty</span></a></span><span>
</span><span id="line-786"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-787"></span><span>     </span><span id="local-6989586621681096614"><span class="annot"><span class="annottext">pred :: PredType
</span><a href="#local-6989586621681096614"><span class="hs-identifier hs-var hs-var">pred</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [PredType] -&gt; PredType
</span><a href="GHC.Core.Predicate.html#mkClassPred"><span class="hs-identifier hs-var">mkClassPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096619"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [PredType]
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTys"><span class="hs-identifier hs-var">mkTyVarTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyConBinder] -&gt; [Id]
forall tv argf. [VarBndr tv argf] -&gt; [tv]
</span><a href="GHC.Types.Var.html#binderVars"><span class="hs-identifier hs-var">binderVars</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681096611"><span class="hs-identifier hs-var">cls_bndrs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-788"></span><span>     </span><span id="local-6989586621681096611"><span class="annot"><span class="annottext">cls_bndrs :: [TyConBinder]
</span><a href="#local-6989586621681096611"><span class="hs-identifier hs-var hs-var">cls_bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TyConBinder]
</span><a href="GHC.Core.TyCon.html#tyConBinders"><span class="hs-identifier hs-var hs-var">tyConBinders</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; TyCon
</span><a href="GHC.Core.Class.html#classTyCon"><span class="hs-identifier hs-var hs-var">classTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681096619"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-789"></span><span>     </span><span id="local-6989586621681096615"><span class="annot"><span class="annottext">tv_bndrs :: [TyCoVarBinder]
</span><a href="#local-6989586621681096615"><span class="hs-identifier hs-var hs-var">tv_bndrs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[VarBndr Id Specificity] -&gt; [TyCoVarBinder]
forall a. [VarBndr a Specificity] -&gt; [VarBndr a ArgFlag]
</span><a href="GHC.Types.Var.html#tyVarSpecToBinders"><span class="hs-identifier hs-var">tyVarSpecToBinders</span></a></span><span> </span><span class="annot"><span class="annottext">([VarBndr Id Specificity] -&gt; [TyCoVarBinder])
-&gt; [VarBndr Id Specificity] -&gt; [TyCoVarBinder]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder] -&gt; [VarBndr Id Specificity]
</span><a href="GHC.Core.TyCon.html#tyConInvisTVBinders"><span class="hs-identifier hs-var">tyConInvisTVBinders</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681096611"><span class="hs-identifier hs-var">cls_bndrs</span></a></span><span>
</span><span id="line-790"></span><span>     </span><span class="hs-comment">-- NB: the Class doesn't have TyConBinders; we reach into its</span><span>
</span><span id="line-791"></span><span>     </span><span class="hs-comment">--     TyCon to get those.  We /do/ need the TyConBinders because</span><span>
</span><span id="line-792"></span><span>     </span><span class="hs-comment">--     we need the correct visibility: these default methods are</span><span>
</span><span id="line-793"></span><span>     </span><span class="hs-comment">--     used in code generated by the fill-in for missing</span><span>
</span><span id="line-794"></span><span>     </span><span class="hs-comment">--     methods in instances (GHC.Tc.TyCl.Instance.mkDefMethBind), and</span><span>
</span><span id="line-795"></span><span>     </span><span class="hs-comment">--     then typechecked.  So we need the right visibility info</span><span>
</span><span id="line-796"></span><span>     </span><span class="hs-comment">--     (#13998)</span><span>
</span><span id="line-797"></span><span>
</span><span id="line-798"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Building record selectors
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-805"></span><span>
</span><span id="line-806"></span><span class="hs-comment">{-
Note [Default method Ids and Template Haskell]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this (#4169):
   class Numeric a where
     fromIntegerNum :: a
     fromIntegerNum = ...

   ast :: Q [Dec]
   ast = [d| instance Numeric Int |]

When we typecheck 'ast' we have done the first pass over the class decl
(in tcTyClDecls), but we have not yet typechecked the default-method
declarations (because they can mention value declarations).  So we
must bring the default method Ids into scope first (so they can be seen
when typechecking the [d| .. |] quote, and typecheck them later.
-}</span><span>
</span><span id="line-823"></span><span>
</span><span id="line-824"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Building record selectors
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-831"></span><span>
</span><span id="line-832"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#tcRecSelBinds"><span class="hs-identifier hs-type">tcRecSelBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span>
</span><span id="line-833"></span><span id="tcRecSelBinds"><span class="annot"><span class="annottext">tcRecSelBinds :: [(Id, LHsBind GhcRn)] -&gt; TcM TcGblEnv
</span><a href="GHC.Tc.TyCl.Utils.html#tcRecSelBinds"><span class="hs-identifier hs-var hs-var">tcRecSelBinds</span></a></span></span><span> </span><span id="local-6989586621681096607"><span class="annot"><span class="annottext">[(Id, LHsBind GhcRn)]
</span><a href="#local-6989586621681096607"><span class="hs-identifier hs-var">sel_bind_prs</span></a></span></span><span>
</span><span id="line-834"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a. [Id] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalValEnv"><span class="hs-identifier hs-var">tcExtendGlobalValEnv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096606"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#IdSig"><span class="hs-identifier hs-type">IdSig</span></a></span><span> </span><span class="annot"><span class="annottext">XIdSig GhcRn
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681096606"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096606"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[GenLocated SrcSpan (Sig GhcRn)]
</span><a href="#local-6989586621681096604"><span class="hs-identifier hs-var">sigs</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(TcM TcGblEnv -&gt; TcM TcGblEnv) -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-835"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096603"><span class="annot"><span class="annottext">[(RecFlag, LHsBinds GhcTc)]
</span><a href="#local-6989586621681096603"><span class="hs-identifier hs-var">rec_sel_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096602"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681096602"><span class="hs-identifier hs-var">tcg_env</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
-&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
forall a. TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#discardWarnings"><span class="hs-identifier hs-var">discardWarnings</span></a></span><span> </span><span class="annot"><span class="annottext">(TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
 -&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv))
-&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
-&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-836"></span><span>                                     </span><span class="hs-comment">-- See Note [Impredicative record selectors]</span><span>
</span><span id="line-837"></span><span>                                     </span><span class="annot"><span class="annottext">Extension
-&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
-&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
forall gbl lcl a. Extension -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setXOptM"><span class="hs-identifier hs-var">setXOptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#ImpredicativeTypes"><span class="hs-identifier hs-var">LangExt.ImpredicativeTypes</span></a></span><span> </span><span class="annot"><span class="annottext">(TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
 -&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv))
-&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
-&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-838"></span><span>                                     </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; [(RecFlag, LHsBinds GhcRn)]
-&gt; [GenLocated SrcSpan (Sig GhcRn)]
-&gt; TcM TcGblEnv
-&gt; TcRn ([(RecFlag, LHsBinds GhcTc)], TcGblEnv)
forall thing.
TopLevelFlag
-&gt; [(RecFlag, LHsBinds GhcRn)]
-&gt; [GenLocated SrcSpan (Sig GhcRn)]
-&gt; TcM thing
-&gt; TcM ([(RecFlag, LHsBinds GhcTc)], thing)
</span><a href="GHC.Tc.Gen.Bind.html#tcValBinds"><span class="hs-identifier hs-var">tcValBinds</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#TopLevel"><span class="hs-identifier hs-var">TopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">[(RecFlag, LHsBinds GhcRn)]
</span><a href="#local-6989586621681096597"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">[GenLocated SrcSpan (Sig GhcRn)]
</span><a href="#local-6989586621681096604"><span class="hs-identifier hs-var">sigs</span></a></span><span> </span><span class="annot"><span class="annottext">TcM TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-839"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM TcGblEnv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681096602"><span class="hs-identifier hs-var">tcg_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; [LHsBinds GhcTc] -&gt; TcGblEnv
</span><a href="GHC.Tc.Utils.Env.html#addTypecheckedBinds"><span class="hs-operator hs-var">`addTypecheckedBinds`</span></a></span><span> </span><span class="annot"><span class="annottext">((RecFlag, LHsBinds GhcTc) -&gt; LHsBinds GhcTc)
-&gt; [(RecFlag, LHsBinds GhcTc)] -&gt; [LHsBinds GhcTc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(RecFlag, LHsBinds GhcTc) -&gt; LHsBinds GhcTc
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">[(RecFlag, LHsBinds GhcTc)]
</span><a href="#local-6989586621681096603"><span class="hs-identifier hs-var">rec_sel_binds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-840"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-841"></span><span>    </span><span id="local-6989586621681096604"><span class="annot"><span class="annottext">sigs :: [GenLocated SrcSpan (Sig GhcRn)]
</span><a href="#local-6989586621681096604"><span class="hs-identifier hs-var hs-var">sigs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; Sig GhcRn -&gt; GenLocated SrcSpan (Sig GhcRn)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096594"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XIdSig GhcRn -&gt; Id -&gt; Sig GhcRn
forall pass. XIdSig pass -&gt; Id -&gt; Sig pass
</span><a href="GHC.Hs.Binds.html#IdSig"><span class="hs-identifier hs-var">IdSig</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XIdSig GhcRn
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096592"><span class="hs-identifier hs-var">sel_id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096592"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096592"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LHsBind GhcRn
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, LHsBind GhcRn)]
</span><a href="#local-6989586621681096607"><span class="hs-identifier hs-var">sel_bind_prs</span></a></span><span>
</span><span id="line-842"></span><span>                                             </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681096594"><span class="annot"><span class="annottext">loc :: SrcSpan
</span><a href="#local-6989586621681096594"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096592"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-843"></span><span>    </span><span id="local-6989586621681096597"><span class="annot"><span class="annottext">binds :: [(RecFlag, LHsBinds GhcRn)]
</span><a href="#local-6989586621681096597"><span class="hs-identifier hs-var hs-var">binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">RecFlag
</span><a href="GHC.Types.Basic.html#NonRecursive"><span class="hs-identifier hs-var">NonRecursive</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LHsBind GhcRn -&gt; LHsBinds GhcRn
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBind GhcRn
</span><a href="#local-6989586621681096589"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096589"><span class="annot"><span class="annottext">LHsBind GhcRn
</span><a href="#local-6989586621681096589"><span class="hs-identifier hs-var">bind</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, LHsBind GhcRn)]
</span><a href="#local-6989586621681096607"><span class="hs-identifier hs-var">sel_bind_prs</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-844"></span><span>
</span><span id="line-845"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkRecSelBinds"><span class="hs-identifier hs-type">mkRecSelBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-846"></span><span class="hs-comment">-- NB We produce *un-typechecked* bindings, rather like 'deriving'</span><span>
</span><span id="line-847"></span><span class="hs-comment">--    This makes life easier, because the later type checking will add</span><span>
</span><span id="line-848"></span><span class="hs-comment">--    all necessary type abstractions and applications</span><span>
</span><span id="line-849"></span><span id="mkRecSelBinds"><span class="annot"><span class="annottext">mkRecSelBinds :: [TyCon] -&gt; [(Id, LHsBind GhcRn)]
</span><a href="GHC.Tc.TyCl.Utils.html#mkRecSelBinds"><span class="hs-identifier hs-var hs-var">mkRecSelBinds</span></a></span></span><span> </span><span id="local-6989586621681096588"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096588"><span class="hs-identifier hs-var">tycons</span></a></span></span><span>
</span><span id="line-850"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((TyCon, FieldLabel) -&gt; (Id, LHsBind GhcRn))
-&gt; [(TyCon, FieldLabel)] -&gt; [(Id, LHsBind GhcRn)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCon, FieldLabel) -&gt; (Id, LHsBind GhcRn)
</span><a href="GHC.Tc.TyCl.Utils.html#mkRecSelBind"><span class="hs-identifier hs-var">mkRecSelBind</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096586"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681096585"><span class="hs-identifier hs-var">fld</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681096586"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096586"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681096588"><span class="hs-identifier hs-var">tycons</span></a></span><span>
</span><span id="line-851"></span><span>                                </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096585"><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681096585"><span class="hs-identifier hs-var">fld</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [FieldLabel]
</span><a href="GHC.Core.TyCon.html#tyConFieldLabels"><span class="hs-identifier hs-var">tyConFieldLabels</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096586"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-852"></span><span>
</span><span id="line-853"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkRecSelBind"><span class="hs-identifier hs-type">mkRecSelBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.FieldLabel.html#FieldLabel"><span class="hs-identifier hs-type">FieldLabel</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-854"></span><span id="mkRecSelBind"><span class="annot"><span class="annottext">mkRecSelBind :: (TyCon, FieldLabel) -&gt; (Id, LHsBind GhcRn)
</span><a href="GHC.Tc.TyCl.Utils.html#mkRecSelBind"><span class="hs-identifier hs-var hs-var">mkRecSelBind</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681096583"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096583"><span class="hs-identifier hs-var">tycon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096582"><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681096582"><span class="hs-identifier hs-var">fl</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-855"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ConLike] -&gt; RecSelParent -&gt; FieldLabel -&gt; (Id, LHsBind GhcRn)
</span><a href="GHC.Tc.TyCl.Utils.html#mkOneRecordSelector"><span class="hs-identifier hs-var">mkOneRecordSelector</span></a></span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681096581"><span class="hs-identifier hs-var">all_cons</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; RecSelParent
</span><a href="GHC.Types.Id.Info.html#RecSelData"><span class="hs-identifier hs-var">RecSelData</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096583"><span class="hs-identifier hs-var">tycon</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681096582"><span class="hs-identifier hs-var">fl</span></a></span><span>
</span><span id="line-856"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-857"></span><span>    </span><span id="local-6989586621681096581"><span class="annot"><span class="annottext">all_cons :: [ConLike]
</span><a href="#local-6989586621681096581"><span class="hs-identifier hs-var hs-var">all_cons</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DataCon -&gt; ConLike) -&gt; [DataCon] -&gt; [ConLike]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; ConLike
</span><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-var">RealDataCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681096583"><span class="hs-identifier hs-var">tycon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-858"></span><span>
</span><span id="line-859"></span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#mkOneRecordSelector"><span class="hs-identifier hs-type">mkOneRecordSelector</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#RecSelParent"><span class="hs-identifier hs-type">RecSelParent</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.FieldLabel.html#FieldLabel"><span class="hs-identifier hs-type">FieldLabel</span></a></span><span>
</span><span id="line-860"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-861"></span><span id="mkOneRecordSelector"><span class="annot"><span class="annottext">mkOneRecordSelector :: [ConLike] -&gt; RecSelParent -&gt; FieldLabel -&gt; (Id, LHsBind GhcRn)
</span><a href="GHC.Tc.TyCl.Utils.html#mkOneRecordSelector"><span class="hs-identifier hs-var hs-var">mkOneRecordSelector</span></a></span></span><span> </span><span id="local-6989586621681096577"><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681096577"><span class="hs-identifier hs-var">all_cons</span></a></span></span><span> </span><span id="local-6989586621681096576"><span class="annot"><span class="annottext">RecSelParent
</span><a href="#local-6989586621681096576"><span class="hs-identifier hs-var">idDetails</span></a></span></span><span> </span><span id="local-6989586621681096575"><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681096575"><span class="hs-identifier hs-var">fl</span></a></span></span><span>
</span><span id="line-862"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681096574"><span class="hs-identifier hs-var">sel_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; HsBind GhcRn -&gt; LHsBind GhcRn
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">HsBind GhcRn
</span><a href="#local-6989586621681096572"><span class="hs-identifier hs-var">sel_bind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-863"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-864"></span><span>    </span><span id="local-6989586621681096573"><span class="annot"><span class="annottext">loc :: SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096571"><span class="hs-identifier hs-var">sel_name</span></a></span><span>
</span><span id="line-865"></span><span>    </span><span id="local-6989586621681096570"><span class="annot"><span class="annottext">lbl :: FieldLabelString
</span><a href="#local-6989586621681096570"><span class="hs-identifier hs-var hs-var">lbl</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FieldLabel -&gt; FieldLabelString
forall a. FieldLbl a -&gt; FieldLabelString
</span><a href="GHC.Types.FieldLabel.html#flLabel"><span class="hs-identifier hs-var hs-var">flLabel</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681096575"><span class="hs-identifier hs-var">fl</span></a></span><span>
</span><span id="line-866"></span><span>    </span><span id="local-6989586621681096571"><span class="annot"><span class="annottext">sel_name :: Name
</span><a href="#local-6989586621681096571"><span class="hs-identifier hs-var hs-var">sel_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FieldLabel -&gt; Name
forall a. FieldLbl a -&gt; a
</span><a href="GHC.Types.FieldLabel.html#flSelector"><span class="hs-identifier hs-var hs-var">flSelector</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681096575"><span class="hs-identifier hs-var">fl</span></a></span><span>
</span><span id="line-867"></span><span>
</span><span id="line-868"></span><span>    </span><span id="local-6989586621681096574"><span class="annot"><span class="annottext">sel_id :: Id
</span><a href="#local-6989586621681096574"><span class="hs-identifier hs-var hs-var">sel_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdDetails -&gt; Name -&gt; PredType -&gt; Id
</span><a href="GHC.Types.Id.html#mkExportedLocalId"><span class="hs-identifier hs-var">mkExportedLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">IdDetails
</span><a href="#local-6989586621681096566"><span class="hs-identifier hs-var">rec_details</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096571"><span class="hs-identifier hs-var">sel_name</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096565"><span class="hs-identifier hs-var">sel_ty</span></a></span><span>
</span><span id="line-869"></span><span>    </span><span id="local-6989586621681096566"><span class="annot"><span class="annottext">rec_details :: IdDetails
</span><a href="#local-6989586621681096566"><span class="hs-identifier hs-var hs-var">rec_details</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecSelId :: RecSelParent -&gt; Bool -&gt; IdDetails
</span><a href="GHC.Types.Id.Info.html#RecSelId"><span class="hs-identifier hs-type">RecSelId</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sel_tycon :: RecSelParent
</span><a href="GHC.Types.Id.Info.html#sel_tycon"><span class="hs-identifier hs-var">sel_tycon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecSelParent
</span><a href="#local-6989586621681096576"><span class="hs-identifier hs-var">idDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sel_naughty :: Bool
</span><a href="GHC.Types.Id.Info.html#sel_naughty"><span class="hs-identifier hs-var">sel_naughty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096561"><span class="hs-identifier hs-var">is_naughty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-870"></span><span>
</span><span id="line-871"></span><span>    </span><span class="hs-comment">-- Find a representative constructor, con1</span><span>
</span><span id="line-872"></span><span>    </span><span id="local-6989586621681096560"><span class="annot"><span class="annottext">cons_w_field :: [ConLike]
</span><a href="#local-6989586621681096560"><span class="hs-identifier hs-var hs-var">cons_w_field</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ConLike] -&gt; [FieldLabelString] -&gt; [ConLike]
</span><a href="GHC.Core.ConLike.html#conLikesWithFields"><span class="hs-identifier hs-var">conLikesWithFields</span></a></span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681096577"><span class="hs-identifier hs-var">all_cons</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681096570"><span class="hs-identifier hs-var">lbl</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-873"></span><span>    </span><span id="local-6989586621681096558"><span class="annot"><span class="annottext">con1 :: ConLike
</span><a href="#local-6989586621681096558"><span class="hs-identifier hs-var hs-var">con1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">cons_w_field</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">head</span><span> </span><span class="hs-identifier">cons_w_field</span><span>
</span><span id="line-874"></span><span>
</span><span id="line-875"></span><span>    </span><span class="hs-comment">-- Selector type; Note [Polymorphic selectors]</span><span>
</span><span id="line-876"></span><span>    </span><span id="local-6989586621681096556"><span class="annot"><span class="annottext">field_ty :: PredType
</span><a href="#local-6989586621681096556"><span class="hs-identifier hs-var hs-var">field_ty</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConLike -&gt; FieldLabelString -&gt; PredType
</span><a href="GHC.Core.ConLike.html#conLikeFieldType"><span class="hs-identifier hs-var">conLikeFieldType</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096558"><span class="hs-identifier hs-var">con1</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681096570"><span class="hs-identifier hs-var">lbl</span></a></span><span>
</span><span id="line-877"></span><span>    </span><span id="local-6989586621681096554"><span class="annot"><span class="annottext">data_tvbs :: [VarBndr Id Specificity]
</span><a href="#local-6989586621681096554"><span class="hs-identifier hs-var hs-var">data_tvbs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarBndr Id Specificity -&gt; Bool)
-&gt; [VarBndr Id Specificity] -&gt; [VarBndr Id Specificity]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681096553"><span class="annot"><span class="annottext">VarBndr Id Specificity
</span><a href="#local-6989586621681096553"><span class="hs-identifier hs-var">tvb</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarBndr Id Specificity -&gt; Id
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span> </span><span class="annot"><span class="annottext">VarBndr Id Specificity
</span><a href="#local-6989586621681096553"><span class="hs-identifier hs-var">tvb</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096552"><span class="hs-identifier hs-var">data_tv_set</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([VarBndr Id Specificity] -&gt; [VarBndr Id Specificity])
-&gt; [VarBndr Id Specificity] -&gt; [VarBndr Id Specificity]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-878"></span><span>                 </span><span class="annot"><span class="annottext">ConLike -&gt; [VarBndr Id Specificity]
</span><a href="GHC.Core.ConLike.html#conLikeUserTyVarBinders"><span class="hs-identifier hs-var">conLikeUserTyVarBinders</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096558"><span class="hs-identifier hs-var">con1</span></a></span><span>
</span><span id="line-879"></span><span>    </span><span id="local-6989586621681096552"><span class="annot"><span class="annottext">data_tv_set :: VarSet
</span><a href="#local-6989586621681096552"><span class="hs-identifier hs-var hs-var">data_tv_set</span></a></span></span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096549"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-880"></span><span>    </span><span id="local-6989586621681096561"><span class="annot"><span class="annottext">is_naughty :: Bool
</span><a href="#local-6989586621681096561"><span class="hs-identifier hs-var hs-var">is_naughty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096556"><span class="hs-identifier hs-var">field_ty</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#subVarSet"><span class="hs-operator hs-var">`subVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681096552"><span class="hs-identifier hs-var">data_tv_set</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-881"></span><span>    </span><span id="local-6989586621681096565"><span class="annot"><span class="annottext">sel_ty :: PredType
</span><a href="#local-6989586621681096565"><span class="hs-identifier hs-var hs-var">sel_ty</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096561"><span class="hs-identifier hs-var">is_naughty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="GHC.Builtin.Types.html#unitTy"><span class="hs-identifier hs-var">unitTy</span></a></span><span>  </span><span class="hs-comment">-- See Note [Naughty record selectors]</span><span>
</span><span id="line-882"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCoVarBinder] -&gt; PredType -&gt; PredType
</span><a href="GHC.Core.TyCo.Rep.html#mkForAllTys"><span class="hs-identifier hs-var">mkForAllTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[VarBndr Id Specificity] -&gt; [TyCoVarBinder]
forall a. [VarBndr a Specificity] -&gt; [VarBndr a ArgFlag]
</span><a href="GHC.Types.Var.html#tyVarSpecToBinders"><span class="hs-identifier hs-var">tyVarSpecToBinders</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr Id Specificity]
</span><a href="#local-6989586621681096554"><span class="hs-identifier hs-var">data_tvbs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(PredType -&gt; PredType) -&gt; PredType -&gt; PredType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-883"></span><span>                          </span><span class="annot"><span class="annottext">[PredType] -&gt; PredType -&gt; PredType
</span><a href="GHC.Tc.Utils.TcType.html#mkPhiTy"><span class="hs-identifier hs-var">mkPhiTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; [PredType]
</span><a href="GHC.Core.ConLike.html#conLikeStupidTheta"><span class="hs-identifier hs-var">conLikeStupidTheta</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096558"><span class="hs-identifier hs-var">con1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(PredType -&gt; PredType) -&gt; PredType -&gt; PredType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>   </span><span class="hs-comment">-- Urgh!</span><span>
</span><span id="line-884"></span><span>                          </span><span class="hs-comment">-- req_theta is empty for normal DataCon</span><span>
</span><span id="line-885"></span><span>                          </span><span class="annot"><span class="annottext">[PredType] -&gt; PredType -&gt; PredType
</span><a href="GHC.Tc.Utils.TcType.html#mkPhiTy"><span class="hs-identifier hs-var">mkPhiTy</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096543"><span class="hs-identifier hs-var">req_theta</span></a></span><span>                 </span><span class="annot"><span class="annottext">(PredType -&gt; PredType) -&gt; PredType -&gt; PredType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-886"></span><span>                          </span><span class="annot"><span class="annottext">PredType -&gt; PredType -&gt; PredType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTyMany"><span class="hs-identifier hs-var">mkVisFunTyMany</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096541"><span class="hs-identifier hs-var">data_ty</span></a></span><span>            </span><span class="annot"><span class="annottext">(PredType -&gt; PredType) -&gt; PredType -&gt; PredType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-887"></span><span>                            </span><span class="hs-comment">-- Record selectors are always typed with Many. We</span><span>
</span><span id="line-888"></span><span>                            </span><span class="hs-comment">-- could improve on it in the case where all the</span><span>
</span><span id="line-889"></span><span>                            </span><span class="hs-comment">-- fields in all the constructor have multiplicity Many.</span><span>
</span><span id="line-890"></span><span>                          </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096556"><span class="hs-identifier hs-var">field_ty</span></a></span><span>
</span><span id="line-891"></span><span>
</span><span id="line-892"></span><span>    </span><span class="hs-comment">-- Make the binding: sel (C2 { fld = x }) = x</span><span>
</span><span id="line-893"></span><span>    </span><span class="hs-comment">--                   sel (C7 { fld = x }) = x</span><span>
</span><span id="line-894"></span><span>    </span><span class="hs-comment">--    where cons_w_field = [C2,C7]</span><span>
</span><span id="line-895"></span><span>    </span><span id="local-6989586621681096572"><span class="annot"><span class="annottext">sel_bind :: HsBind GhcRn
</span><a href="#local-6989586621681096572"><span class="hs-identifier hs-var hs-var">sel_bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Origin
-&gt; Located Name -&gt; [LMatch GhcRn (LHsExpr GhcRn)] -&gt; HsBind GhcRn
</span><a href="GHC.Hs.Utils.html#mkTopFunBind"><span class="hs-identifier hs-var">mkTopFunBind</span></a></span><span> </span><span class="annot"><span class="annottext">Origin
</span><a href="GHC.Types.Basic.html#Generated"><span class="hs-identifier hs-var">Generated</span></a></span><span> </span><span class="annot"><span class="annottext">Located Name
</span><a href="#local-6989586621681096538"><span class="hs-identifier hs-var">sel_lname</span></a></span><span> </span><span class="annot"><span class="annottext">[LMatch GhcRn (LHsExpr GhcRn)]
</span><a href="#local-6989586621681096537"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-896"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-897"></span><span>        </span><span id="local-6989586621681096537"><span class="annot"><span class="annottext">alts :: [LMatch GhcRn (LHsExpr GhcRn)]
</span><a href="#local-6989586621681096537"><span class="hs-identifier hs-var hs-var">alts</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681096561"><span class="hs-identifier hs-var">is_naughty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">HsMatchContext (NoGhcTc GhcRn)
-&gt; [LPat GhcRn] -&gt; LHsExpr GhcRn -&gt; LMatch GhcRn (LHsExpr GhcRn)
forall (p :: Pass) (body :: * -&gt; *).
HsMatchContext (NoGhcTc (GhcPass p))
-&gt; [LPat (GhcPass p)]
-&gt; Located (body (GhcPass p))
-&gt; LMatch (GhcPass p) (Located (body (GhcPass p)))
</span><a href="GHC.Hs.Utils.html#mkSimpleMatch"><span class="hs-identifier hs-var">mkSimpleMatch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Located (IdP GhcRn) -&gt; HsMatchContext GhcRn
forall p. LIdP p -&gt; HsMatchContext p
</span><a href="GHC.Hs.Utils.html#mkPrefixFunRhs"><span class="hs-identifier hs-var">mkPrefixFunRhs</span></a></span><span> </span><span class="annot"><span class="annottext">Located Name
Located (IdP GhcRn)
</span><a href="#local-6989586621681096538"><span class="hs-identifier hs-var">sel_lname</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-898"></span><span>                                           </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">LHsExpr GhcRn
forall {a :: Pass}. LHsExpr (GhcPass a)
</span><a href="#local-6989586621681096534"><span class="hs-identifier hs-var">unit_rhs</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-899"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">(ConLike -&gt; LMatch GhcRn (LHsExpr GhcRn))
-&gt; [ConLike] -&gt; [LMatch GhcRn (LHsExpr GhcRn)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike -&gt; LMatch GhcRn (LHsExpr GhcRn)
</span><a href="#local-6989586621681096533"><span class="hs-identifier hs-var">mk_match</span></a></span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681096560"><span class="hs-identifier hs-var">cons_w_field</span></a></span><span> </span><span class="annot"><span class="annottext">[LMatch GhcRn (LHsExpr GhcRn)]
-&gt; [LMatch GhcRn (LHsExpr GhcRn)] -&gt; [LMatch GhcRn (LHsExpr GhcRn)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[LMatch GhcRn (LHsExpr GhcRn)]
</span><a href="#local-6989586621681096532"><span class="hs-identifier hs-var">deflt</span></a></span><span>
</span><span id="line-900"></span><span>    </span><span id="local-6989586621681096533"><span class="annot"><span class="annottext">mk_match :: ConLike -&gt; LMatch GhcRn (LHsExpr GhcRn)
</span><a href="#local-6989586621681096533"><span class="hs-identifier hs-var hs-var">mk_match</span></a></span></span><span> </span><span id="local-6989586621681096531"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096531"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsMatchContext (NoGhcTc GhcRn)
-&gt; [LPat GhcRn] -&gt; LHsExpr GhcRn -&gt; LMatch GhcRn (LHsExpr GhcRn)
forall (p :: Pass) (body :: * -&gt; *).
HsMatchContext (NoGhcTc (GhcPass p))
-&gt; [LPat (GhcPass p)]
-&gt; Located (body (GhcPass p))
-&gt; LMatch (GhcPass p) (Located (body (GhcPass p)))
</span><a href="GHC.Hs.Utils.html#mkSimpleMatch"><span class="hs-identifier hs-var">mkSimpleMatch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Located (IdP GhcRn) -&gt; HsMatchContext GhcRn
forall p. LIdP p -&gt; HsMatchContext p
</span><a href="GHC.Hs.Utils.html#mkPrefixFunRhs"><span class="hs-identifier hs-var">mkPrefixFunRhs</span></a></span><span> </span><span class="annot"><span class="annottext">Located Name
Located (IdP GhcRn)
</span><a href="#local-6989586621681096538"><span class="hs-identifier hs-var">sel_lname</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-901"></span><span>                                 </span><span class="hs-special">[</span><span class="annot"><span class="annottext">SrcSpan -&gt; Pat GhcRn -&gt; GenLocated SrcSpan (Pat GhcRn)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; Pat GhcRn
</span><a href="#local-6989586621681096530"><span class="hs-identifier hs-var">mk_sel_pat</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096531"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-902"></span><span>                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcRn -&gt; LHsExpr GhcRn
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XVar GhcRn -&gt; Located (IdP GhcRn) -&gt; HsExpr GhcRn
forall p. XVar p -&gt; Located (IdP p) -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsVar"><span class="hs-identifier hs-var">HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XVar GhcRn
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; Name -&gt; Located Name
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096528"><span class="hs-identifier hs-var">field_var</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-903"></span><span>    </span><span id="local-6989586621681096530"><span class="annot"><span class="annottext">mk_sel_pat :: ConLike -&gt; Pat GhcRn
</span><a href="#local-6989586621681096530"><span class="hs-identifier hs-var hs-var">mk_sel_pat</span></a></span></span><span> </span><span id="local-6989586621681096527"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096527"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">XConPat GhcRn
-&gt; Located (ConLikeP GhcRn) -&gt; HsConPatDetails GhcRn -&gt; Pat GhcRn
forall p.
XConPat p -&gt; Located (ConLikeP p) -&gt; HsConPatDetails p -&gt; Pat p
</span><a href="GHC.Hs.Pat.html#ConPat"><span class="hs-identifier hs-var">ConPat</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XConPat GhcRn
</span><a href="GHC.Hs.Extension.html#NoExtField"><span class="hs-identifier hs-var">NoExtField</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; Name -&gt; Located Name
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096527"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsRecFields GhcRn (GenLocated SrcSpan (Pat GhcRn))
-&gt; HsConDetails
     (GenLocated SrcSpan (Pat GhcRn))
     (HsRecFields GhcRn (GenLocated SrcSpan (Pat GhcRn)))
forall arg rec. rec -&gt; HsConDetails arg rec
</span><a href="GHC.Hs.Type.html#RecCon"><span class="hs-identifier hs-var">RecCon</span></a></span><span> </span><span class="annot"><span class="annottext">HsRecFields GhcRn (GenLocated SrcSpan (Pat GhcRn))
</span><a href="#local-6989586621681096523"><span class="hs-identifier hs-var">rec_fields</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-904"></span><span>    </span><span id="local-6989586621681096523"><span class="annot"><span class="annottext">rec_fields :: HsRecFields GhcRn (GenLocated SrcSpan (Pat GhcRn))
</span><a href="#local-6989586621681096523"><span class="hs-identifier hs-var hs-var">rec_fields</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsRecFields :: forall p arg.
[LHsRecField p arg] -&gt; Maybe (Located Int) -&gt; HsRecFields p arg
</span><a href="GHC.Hs.Pat.html#HsRecFields"><span class="hs-identifier hs-type">HsRecFields</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">rec_flds :: [LHsRecField GhcRn (GenLocated SrcSpan (Pat GhcRn))]
</span><a href="GHC.Hs.Pat.html#rec_flds"><span class="hs-identifier hs-var">rec_flds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">LHsRecField GhcRn (GenLocated SrcSpan (Pat GhcRn))
</span><a href="#local-6989586621681096520"><span class="hs-identifier hs-var">rec_field</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">rec_dotdot :: Maybe (Located Int)
</span><a href="GHC.Hs.Pat.html#rec_dotdot"><span class="hs-identifier hs-var">rec_dotdot</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Located Int)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-905"></span><span>    </span><span id="local-6989586621681096520"><span class="annot"><span class="annottext">rec_field :: LHsRecField GhcRn (GenLocated SrcSpan (Pat GhcRn))
</span><a href="#local-6989586621681096520"><span class="hs-identifier hs-var hs-var">rec_field</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsRecField' (FieldOcc GhcRn) (GenLocated SrcSpan (Pat GhcRn))
-&gt; LHsRecField GhcRn (GenLocated SrcSpan (Pat GhcRn))
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsRecField :: forall id arg. Located id -&gt; arg -&gt; Bool -&gt; HsRecField' id arg
</span><a href="GHC.Hs.Pat.html#HsRecField"><span class="hs-identifier hs-type">HsRecField</span></a></span><span>
</span><span id="line-906"></span><span>                        </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hsRecFieldLbl :: Located (FieldOcc GhcRn)
</span><a href="GHC.Hs.Pat.html#hsRecFieldLbl"><span class="hs-identifier hs-var">hsRecFieldLbl</span></a></span><span>
</span><span id="line-907"></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; FieldOcc GhcRn -&gt; Located (FieldOcc GhcRn)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XCFieldOcc GhcRn -&gt; Located RdrName -&gt; FieldOcc GhcRn
forall pass. XCFieldOcc pass -&gt; Located RdrName -&gt; FieldOcc pass
</span><a href="GHC.Hs.Type.html#FieldOcc"><span class="hs-identifier hs-var">FieldOcc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
XCFieldOcc GhcRn
</span><a href="#local-6989586621681096571"><span class="hs-identifier hs-var">sel_name</span></a></span><span>
</span><span id="line-908"></span><span>                                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; RdrName -&gt; Located RdrName
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; Located RdrName) -&gt; RdrName -&gt; Located RdrName
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString -&gt; RdrName
</span><a href="GHC.Types.Name.Reader.html#mkVarUnqual"><span class="hs-identifier hs-var">mkVarUnqual</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681096570"><span class="hs-identifier hs-var">lbl</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-909"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hsRecFieldArg :: GenLocated SrcSpan (Pat GhcRn)
</span><a href="GHC.Hs.Pat.html#hsRecFieldArg"><span class="hs-identifier hs-var">hsRecFieldArg</span></a></span><span>
</span><span id="line-910"></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; Pat GhcRn -&gt; GenLocated SrcSpan (Pat GhcRn)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XVarPat GhcRn -&gt; Located (IdP GhcRn) -&gt; Pat GhcRn
forall p. XVarPat p -&gt; Located (IdP p) -&gt; Pat p
</span><a href="GHC.Hs.Pat.html#VarPat"><span class="hs-identifier hs-var">VarPat</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XVarPat GhcRn
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; Name -&gt; Located Name
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096528"><span class="hs-identifier hs-var">field_var</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-911"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hsRecPun :: Bool
</span><a href="GHC.Hs.Pat.html#hsRecPun"><span class="hs-identifier hs-var">hsRecPun</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-912"></span><span>    </span><span id="local-6989586621681096538"><span class="annot"><span class="annottext">sel_lname :: Located Name
</span><a href="#local-6989586621681096538"><span class="hs-identifier hs-var hs-var">sel_lname</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; Name -&gt; Located Name
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096571"><span class="hs-identifier hs-var">sel_name</span></a></span><span>
</span><span id="line-913"></span><span>    </span><span id="local-6989586621681096528"><span class="annot"><span class="annottext">field_var :: Name
</span><a href="#local-6989586621681096528"><span class="hs-identifier hs-var hs-var">field_var</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; SrcSpan -&gt; Name
</span><a href="GHC.Types.Name.html#mkInternalName"><span class="hs-identifier hs-var">mkInternalName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Unique
</span><a href="GHC.Types.Unique.html#mkBuiltinUnique"><span class="hs-identifier hs-var">mkBuiltinUnique</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681096571"><span class="hs-identifier hs-var">sel_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-914"></span><span>
</span><span id="line-915"></span><span>    </span><span class="hs-comment">-- Add catch-all default case unless the case is exhaustive</span><span>
</span><span id="line-916"></span><span>    </span><span class="hs-comment">-- We do this explicitly so that we get a nice error message that</span><span>
</span><span id="line-917"></span><span>    </span><span class="hs-comment">-- mentions this particular record selector</span><span>
</span><span id="line-918"></span><span>    </span><span id="local-6989586621681096532"><span class="annot"><span class="annottext">deflt :: [LMatch GhcRn (LHsExpr GhcRn)]
</span><a href="#local-6989586621681096532"><span class="hs-identifier hs-var hs-var">deflt</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(ConLike -&gt; Bool) -&gt; [ConLike] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike -&gt; Bool
</span><a href="#local-6989586621681096509"><span class="hs-identifier hs-var">dealt_with</span></a></span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681096577"><span class="hs-identifier hs-var">all_cons</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-919"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">HsMatchContext (NoGhcTc GhcRn)
-&gt; [LPat GhcRn] -&gt; LHsExpr GhcRn -&gt; LMatch GhcRn (LHsExpr GhcRn)
forall (p :: Pass) (body :: * -&gt; *).
HsMatchContext (NoGhcTc (GhcPass p))
-&gt; [LPat (GhcPass p)]
-&gt; Located (body (GhcPass p))
-&gt; LMatch (GhcPass p) (Located (body (GhcPass p)))
</span><a href="GHC.Hs.Utils.html#mkSimpleMatch"><span class="hs-identifier hs-var">mkSimpleMatch</span></a></span><span> </span><span class="annot"><span class="annottext">HsMatchContext (NoGhcTc GhcRn)
forall p. HsMatchContext p
</span><a href="GHC.Hs.Expr.html#CaseAlt"><span class="hs-identifier hs-var">CaseAlt</span></a></span><span>
</span><span id="line-920"></span><span>                            </span><span class="hs-special">[</span><span class="annot"><span class="annottext">SrcSpan -&gt; Pat GhcRn -&gt; GenLocated SrcSpan (Pat GhcRn)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XWildPat GhcRn -&gt; Pat GhcRn
forall p. XWildPat p -&gt; Pat p
</span><a href="GHC.Hs.Pat.html#WildPat"><span class="hs-identifier hs-var">WildPat</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XWildPat GhcRn
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-921"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsExpr GhcRn -&gt; LHsExpr GhcRn -&gt; LHsExpr GhcRn
forall (id :: Pass).
LHsExpr (GhcPass id)
-&gt; LHsExpr (GhcPass id) -&gt; LHsExpr (GhcPass id)
</span><a href="GHC.Hs.Utils.html#mkHsApp"><span class="hs-identifier hs-var">mkHsApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcRn -&gt; LHsExpr GhcRn
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XVar GhcRn -&gt; Located (IdP GhcRn) -&gt; HsExpr GhcRn
forall p. XVar p -&gt; Located (IdP p) -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsVar"><span class="hs-identifier hs-var">HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XVar GhcRn
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span>
</span><span id="line-922"></span><span>                                         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; Name -&gt; Located Name
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="GHC.Core.Make.html#rEC_SEL_ERROR_ID"><span class="hs-identifier hs-var">rEC_SEL_ERROR_ID</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-923"></span><span>                                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcRn -&gt; LHsExpr GhcRn
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681096573"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XLitE GhcRn -&gt; HsLit GhcRn -&gt; HsExpr GhcRn
forall p. XLitE p -&gt; HsLit p -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsLit"><span class="hs-identifier hs-var">HsLit</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XLitE GhcRn
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="annot"><span class="annottext">HsLit GhcRn
</span><a href="#local-6989586621681096504"><span class="hs-identifier hs-var">msg_lit</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-924"></span><span>
</span><span id="line-925"></span><span>        </span><span class="hs-comment">-- Do not add a default case unless there are unmatched</span><span>
</span><span id="line-926"></span><span>        </span><span class="hs-comment">-- constructors.  We must take account of GADTs, else we</span><span>
</span><span id="line-927"></span><span>        </span><span class="hs-comment">-- get overlap warning messages from the pattern-match checker</span><span>
</span><span id="line-928"></span><span>        </span><span class="hs-comment">-- NB: we need to pass type args for the *representation* TyCon</span><span>
</span><span id="line-929"></span><span>        </span><span class="hs-comment">--     to dataConCannotMatch, hence the calculation of inst_tys</span><span>
</span><span id="line-930"></span><span>        </span><span class="hs-comment">--     This matters in data families</span><span>
</span><span id="line-931"></span><span>        </span><span class="hs-comment">--              data instance T Int a where</span><span>
</span><span id="line-932"></span><span>        </span><span class="hs-comment">--                 A :: { fld :: Int } -&gt; T Int Bool</span><span>
</span><span id="line-933"></span><span>        </span><span class="hs-comment">--                 B :: { fld :: Int } -&gt; T Int Char</span><span>
</span><span id="line-934"></span><span>    </span><span class="annot"><a href="#local-6989586621681096509"><span class="hs-identifier hs-type">dealt_with</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-935"></span><span>    </span><span id="local-6989586621681096509"><span class="annot"><span class="annottext">dealt_with :: ConLike -&gt; Bool
</span><a href="#local-6989586621681096509"><span class="hs-identifier hs-var hs-var">dealt_with</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#PatSynCon"><span class="hs-identifier hs-type">PatSynCon</span></a></span><span> </span><span class="annot"><span class="annottext">PatSyn
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-comment">-- We can't predict overlap</span><span>
</span><span id="line-936"></span><span>    </span><span class="annot"><a href="#local-6989586621681096509"><span class="hs-identifier hs-var">dealt_with</span></a></span><span> </span><span id="local-6989586621681096502"><span class="annot"><span class="annottext">con :: ConLike
</span><a href="#local-6989586621681096502"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span id="local-6989586621681096501"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681096501"><span class="hs-identifier hs-var">dc</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-937"></span><span>      </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096502"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike -&gt; [ConLike] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681096560"><span class="hs-identifier hs-var">cons_w_field</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; DataCon -&gt; Bool
</span><a href="GHC.Core.DataCon.html#dataConCannotMatch"><span class="hs-identifier hs-var">dataConCannotMatch</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096549"><span class="hs-identifier hs-var">inst_tys</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681096501"><span class="hs-identifier hs-var">dc</span></a></span><span>
</span><span id="line-938"></span><span>
</span><span id="line-939"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681096498"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096498"><span class="hs-identifier hs-var">univ_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096497"><span class="annot"><span class="annottext">[EqSpec]
</span><a href="#local-6989586621681096497"><span class="hs-identifier hs-var">eq_spec</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096543"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681096543"><span class="hs-identifier hs-var">req_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Scaled PredType]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681096541"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681096541"><span class="hs-identifier hs-var">data_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConLike
-&gt; ([Id], [Id], [EqSpec], [PredType], [PredType],
    [Scaled PredType], PredType)
</span><a href="GHC.Core.ConLike.html#conLikeFullSig"><span class="hs-identifier hs-var">conLikeFullSig</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681096558"><span class="hs-identifier hs-var">con1</span></a></span><span>
</span><span id="line-940"></span><span>
</span><span id="line-941"></span><span>    </span><span id="local-6989586621681096495"><span class="annot"><span class="annottext">eq_subst :: TCvSubst
</span><a href="#local-6989586621681096495"><span class="hs-identifier hs-var hs-var">eq_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, PredType)] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubstPrs"><span class="hs-identifier hs-var">mkTvSubstPrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(EqSpec -&gt; (Id, PredType)) -&gt; [EqSpec] -&gt; [(Id, PredType)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">EqSpec -&gt; (Id, PredType)
</span><a href="GHC.Core.DataCon.html#eqSpecPair"><span class="hs-identifier hs-var">eqSpecPair</span></a></span><span> </span><span class="annot"><span class="annottext">[EqSpec]
</span><a href="#local-6989586621681096497"><span class="hs-identifier hs-var">eq_spec</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-942"></span><span>    </span><span class="hs-comment">-- inst_tys corresponds to one of the following:</span><span>
</span><span id="line-943"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-944"></span><span>    </span><span class="hs-comment">-- * The arguments to the user-written return type (for GADT constructors).</span><span>
</span><span id="line-945"></span><span>    </span><span class="hs-comment">--   In this scenario, eq_subst provides a mapping from the universally</span><span>
</span><span id="line-946"></span><span>    </span><span class="hs-comment">--   quantified type variables to the argument types. Note that eq_subst</span><span>
</span><span id="line-947"></span><span>    </span><span class="hs-comment">--   does not need to be applied to any other part of the DataCon</span><span>
</span><span id="line-948"></span><span>    </span><span class="hs-comment">--   (see Note [The dcEqSpec domain invariant] in GHC.Core.DataCon).</span><span>
</span><span id="line-949"></span><span>    </span><span class="hs-comment">-- * The universally quantified type variables</span><span>
</span><span id="line-950"></span><span>    </span><span class="hs-comment">--   (for Haskell98-style constructors and pattern synonyms). In these</span><span>
</span><span id="line-951"></span><span>    </span><span class="hs-comment">--   scenarios, eq_subst is an empty substitution.</span><span>
</span><span id="line-952"></span><span>    </span><span id="local-6989586621681096549"><span class="annot"><span class="annottext">inst_tys :: [PredType]
</span><a href="#local-6989586621681096549"><span class="hs-identifier hs-var hs-var">inst_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Id] -&gt; [PredType]
</span><a href="GHC.Core.TyCo.Subst.html#substTyVars"><span class="hs-identifier hs-var">substTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681096495"><span class="hs-identifier hs-var">eq_subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681096498"><span class="hs-identifier hs-var">univ_tvs</span></a></span><span>
</span><span id="line-953"></span><span>
</span><span id="line-954"></span><span>    </span><span id="local-6989586621681096534"><span class="annot"><span class="annottext">unit_rhs :: LHsExpr (GhcPass a)
</span><a href="#local-6989586621681096534"><span class="hs-identifier hs-var hs-var">unit_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LHsExpr (GhcPass a)] -&gt; LHsExpr (GhcPass a)
forall (a :: Pass). [LHsExpr (GhcPass a)] -&gt; LHsExpr (GhcPass a)
</span><a href="GHC.Hs.Utils.html#mkLHsTupleExpr"><span class="hs-identifier hs-var">mkLHsTupleExpr</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-955"></span><span>    </span><span id="local-6989586621681096504"><span class="annot"><span class="annottext">msg_lit :: HsLit GhcRn
</span><a href="#local-6989586621681096504"><span class="hs-identifier hs-var hs-var">msg_lit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">XHsStringPrim GhcRn -&gt; ByteString -&gt; HsLit GhcRn
forall x. XHsStringPrim x -&gt; ByteString -&gt; HsLit x
</span><a href="GHC.Hs.Lit.html#HsStringPrim"><span class="hs-identifier hs-var">HsStringPrim</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
XHsStringPrim GhcRn
</span><a href="GHC.Types.Basic.html#NoSourceText"><span class="hs-identifier hs-var">NoSourceText</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabelString -&gt; ByteString
</span><a href="GHC.Data.FastString.html#bytesFS"><span class="hs-identifier hs-var">bytesFS</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681096570"><span class="hs-identifier hs-var">lbl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-956"></span><span>
</span><span id="line-957"></span><span class="hs-comment">{-
Note [Polymorphic selectors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We take care to build the type of a polymorphic selector in the right
order, so that visible type application works according to the specification in
the GHC User's Guide (see the &quot;Field selectors and TypeApplications&quot; section).
We won't bother rehashing the entire specification in this Note, but the tricky
part is dealing with GADT constructor fields. Here is an appropriately tricky
example to illustrate the challenges:

  {-# LANGUAGE PolyKinds #-}
  data T a b where
    MkT :: forall b a x.
           { field1 :: forall c. (Num a, Show c) =&gt; (Either a c, Proxy b)
           , field2 :: x
           }
        -&gt; T a b

Our goal is to obtain the following type for `field1`:

  field1 :: forall {k} (b :: k) a.
            T a b -&gt; forall c. (Num a, Show c) =&gt; (Either a c, Proxy b)

(`field2` is naughty, per Note [Naughty record selectors], so we cannot turn
it into a top-level field selector.)

Some potential gotchas, inspired by #18023:

1. Since the user wrote `forall b a x.` in the type of `MkT`, we want the `b`
   to appear before the `a` when quantified in the type of `field1`.
2. On the other hand, we *don't* want to quantify `x` in the type of `field1`.
   This is because `x` does not appear in the GADT return type, so it is not
   needed in the selector type.
3. Because of PolyKinds, the kind of `b` is generalized to `k`. Moreover, since
   this `k` is not written in the source code, it is inferred (i.e., not
   available for explicit type applications) and thus written as {k} in the type
   of `field1`.

In order to address these gotchas, we start by looking at the
conLikeUserTyVarBinders, which gives the order and specificity of each binder.
This effectively solves (1) and (3). To solve (2), we filter the binders to
leave only those that are needed for the selector type.

Note [Naughty record selectors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A &quot;naughty&quot; field is one for which we can't define a record
selector, because an existential type variable would escape.  For example:
        data T = forall a. MkT { x,y::a }
We obviously can't define
        x (MkT v _) = v
Nevertheless we *do* put a RecSelId into the type environment
so that if the user tries to use 'x' as a selector we can bleat
helpfully, rather than saying unhelpfully that 'x' is not in scope.
Hence the sel_naughty flag, to identify record selectors that don't really exist.

In general, a field is &quot;naughty&quot; if its type mentions a type variable that
isn't in the result type of the constructor.  Note that this *allows*
GADT record selectors (Note [GADT record selectors]) whose types may look
like     sel :: T [a] -&gt; a

For naughty selectors we make a dummy binding
   sel = ()
so that the later type-check will add them to the environment, and they'll be
exported.  The function is never called, because the typechecker spots the
sel_naughty field.

Note [GADT record selectors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For GADTs, we require that all constructors with a common field 'f' have the same
result type (modulo alpha conversion).  [Checked in GHC.Tc.TyCl.checkValidTyCon]
E.g.
        data T where
          T1 { f :: Maybe a } :: T [a]
          T2 { f :: Maybe a, y :: b  } :: T [a]
          T3 :: T Int

and now the selector takes that result type as its argument:
   f :: forall a. T [a] -&gt; Maybe a

Details: the &quot;real&quot; types of T1,T2 are:
   T1 :: forall r a.   (r~[a]) =&gt; a -&gt; T r
   T2 :: forall r a b. (r~[a]) =&gt; a -&gt; b -&gt; T r

So the selector loooks like this:
   f :: forall a. T [a] -&gt; Maybe a
   f (a:*) (t:T [a])
     = case t of
         T1 c   (g:[a]~[c]) (v:Maybe c)       -&gt; v `cast` Maybe (right (sym g))
         T2 c d (g:[a]~[c]) (v:Maybe c) (w:d) -&gt; v `cast` Maybe (right (sym g))
         T3 -&gt; error &quot;T3 does not have field f&quot;

Note the forall'd tyvars of the selector are just the free tyvars
of the result type; there may be other tyvars in the constructor's
type (e.g. 'b' in T2).

Note the need for casts in the result!

Note [Selector running example]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's OK to combine GADTs and type families.  Here's a running example:

        data instance T [a] where
          T1 { fld :: b } :: T [Maybe b]

The representation type looks like this
        data :R7T a where
          T1 { fld :: b } :: :R7T (Maybe b)

and there's coercion from the family type to the representation type
        :CoR7T a :: T [a] ~ :R7T a

The selector we want for fld looks like this:

        fld :: forall b. T [Maybe b] -&gt; b
        fld = /\b. \(d::T [Maybe b]).
              case d `cast` :CoR7T (Maybe b) of
                T1 (x::b) -&gt; x

The scrutinee of the case has type :R7T (Maybe b), which can be
gotten by applying the eq_spec to the univ_tvs of the data con.

Note [Impredicative record selectors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are situations where generating code for record selectors requires the
use of ImpredicativeTypes. Here is one example (adapted from #18005):

  type S = (forall b. b -&gt; b) -&gt; Int
  data T = MkT {unT :: S}
         | Dummy

We want to generate HsBinds for unT that look something like this:

  unT :: S
  unT (MkT x) = x
  unT _       = recSelError &quot;unT&quot;#

Note that the type of recSelError is `forall r (a :: TYPE r). Addr# -&gt; a`.
Therefore, when used in the right-hand side of `unT`, GHC attempts to
instantiate `a` with `(forall b. b -&gt; b) -&gt; Int`, which is impredicative.
To make sure that GHC is OK with this, we enable ImpredicativeTypes interally
when typechecking these HsBinds so that the user does not have to.

Although ImpredicativeTypes is somewhat fragile and unpredictable in GHC right
now, it will become robust when Quick Look impredicativity is implemented. In
the meantime, using ImpredicativeTypes to instantiate the `a` type variable in
recSelError's type does actually work, so its use here is benign.
-}</span><span>
</span><span id="line-1104"></span></pre></body></html>